CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by johnraff on Thu 10th Mar 13:09 (modification of post by johnraff view diff)
diff | download | new post

  1. # This is a modified version of the example plymouth plugin script
  2.  
  3. screen_width = Window.GetWidth();
  4. screen_height = Window.GetHeight();
  5.  
  6. Window.SetBackgroundTopColor(0, 0, 0);
  7. Window.SetBackgro# This is a modified version of the example plymouth plugin script
  8.  
  9. screen_width = Window.GetWidth();
  10. screen_height = Window.GetHeight();
  11.  
  12. Window.SetBackgroundTopColor(0, 0, 0);
  13. Window.SetBackgroundBottomColor(0, 0, 0);
  14.  
  15. # screen width logo image was made to look best on
  16. logo_image_original_screen_width = 1024;
  17. logo_scale_factor = screen_width / logo_image_original_screen_width;
  18.  
  19. #logo.image = Image("special://logo");
  20. logo.original_image = Image ("crunchbang-logo.png");
  21. logo_width = logo.original_image.GetWidth() * logo_scale_factor;
  22. logo_height = logo.original_image.GetHeight() * logo_scale_factor;
  23. logo.image = logo.original_image.Scale(logo_width, logo_height);
  24. logo.sprite = Sprite(logo.image);
  25. logo.opacity_angle = 0;
  26.  
  27.  
  28. fun refresh_callback ()
  29.   {
  30.     if (status == "normal")
  31.       {
  32.         logo.opacity_angle += ((2 * 3.14) / 50) * 0.5;  # 0.5 HZ
  33.         min_opacity = 0.3;
  34.         opacity = (Math.Cos(logo.opacity_angle) + 1) / 2;
  35.         opacity *= 1 - min_opacity;
  36.         opacity += min_opacity;
  37.         logo.sprite.SetX (Window.GetX() + screen_width  / 2 - logo_width  / 2);
  38.         logo.sprite.SetY (Window.GetY() + screen_height / 2 - logo_height / 2);
  39.         logo.sprite.SetOpacity (opacity);
  40.       }
  41.     else
  42.       {
  43.         logo.sprite.SetX (0);
  44.         logo.sprite.SetY (0);
  45.         logo.sprite.SetOpacity (1);
  46.       }
  47.   }
  48.  
  49. Plymouth.SetRefreshFunction (refresh_callback);
  50.  
  51. status = "normal";
  52.  
  53. #----------------------------------------- Progress Bar --------------------------------
  54. progress_box_height = (logo_height * 0.1);
  55. progress_box_width = (screen_width * 0.4);
  56.  
  57. progress_box.original_image = Image("progress_box.png");
  58. progress_box.image = progress_box.original_image.Scale(progress_box_width, progress_box_height);
  59. progress_box.sprite = Sprite(progress_box.image);
  60.  
  61. progress_box.x = Window.GetX() + screen_width / 2 - progress_box_width / 2;
  62. progress_box.y = Window.GetY() + screen_height / 2 + logo_height / 2 + progress_box_height * 5;
  63. progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0);
  64.  
  65. progress_bar.original_image = Image("progress_bar.png");
  66. progress_bar.image = progress_bar.original_image.Scale(0, progress_box_height);
  67. progress_bar.sprite = Sprite();
  68.  
  69. progress_bar.x = progress_box.x;
  70. progress_bar.y = progress_box.y;
  71. progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1);
  72.  
  73. # "progress * 3" for bar width is a hack which should be unnecessary
  74. fun progress_callback (duration, progress)
  75.   {
  76. # I don't understand the purpose of this line, but changed it anyway
  77. #    if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress))
  78.     if (progress_bar.image.GetWidth () != Math.Int (progress_box_width * progress))
  79.       {
  80.         progress_bar.image = progress_bar.original_image.Scale(progress_box_width * progress * 3, progress_box_height);
  81.         progress_bar.sprite.SetImage (progress_bar.image);
  82.       }
  83.   }
  84.  
  85. Plymouth.SetBootProgressFunction(progress_callback);
  86.  
  87. #----------------------------------------- Status Update --------------------------------
  88.  
  89. NUM_SCROLL_LINES = 5;
  90. LINE_WIDTH = 55;
  91. # width of one character
  92. CHAR_WIDTH = 7;
  93. # height of one character
  94. CHAR_HEIGHT = 10;
  95.  
  96. fun StringLength(string) {
  97.   index = 0;
  98.   str = String(string);
  99.   while(str.CharAt(index)) index++;
  100.   return index;
  101. }
  102.  
  103. // Initialising text images and their positions
  104. // CHAR_HEIGHT * 2 is the height (including line spacing) of each line
  105. for (i=0; i < NUM_SCROLL_LINES; i++) {
  106.   lines[i]= Image.Text("");
  107.   message_sprite[i] = Sprite();
  108.   message_sprite[i].SetX (Window.GetX() + (screen_width / 2 ) - (LINE_WIDTH * CHAR_WIDTH / 2));
  109.   message_sprite[i].SetY (Window.GetY() + (screen_height / 2) + (logo_height /2) +(logo_height * 1.2)+ (i * CHAR_HEIGHT * 2) );
  110.   message_sprite[i].SetZ (10000);
  111. }
  112.  
  113.  
  114. fun scroll_message_callback(text) {
  115.  
  116.    // Truncate the message if too long
  117.    if (StringLength(text) > LINE_WIDTH) {
  118.      text = text.SubString(0, LINE_WIDTH - 3);
  119.      text += "...";
  120.    }
  121.  
  122.    // Shift messages one up
  123.    for (i = 0; i < NUM_SCROLL_LINES - 1; i++) {
  124.      lines[i] = lines[i+1];
  125.    }
  126.  
  127.    // Create the image for the latest message
  128. #  i is a global variable here? It needs to be equal to NUM_SCROLL_LINES - 1
  129.    lines[i] = Image.Text( text, 0.5, 0.5, 0.5);
  130.  
  131.    // Re-allocate the text images to sprites
  132.    for (i = 0; i < NUM_SCROLL_LINES; i++) {
  133.      message_sprite[i].SetImage(lines[i]);
  134.    }
  135. }
  136.  
  137. Plymouth.SetUpdateStatusFunction(scroll_message_callback);
  138.  
  139. # messages get added to updates
  140. Plymouth.SetMessageFunction(scroll_message_callback);
  141.  
  142. #----------------------------------------- Quit --------------------------------
  143.  
  144. fun quit_callback ()
  145. {
  146.   logo.sprite.SetOpacity (1);
  147.   progress_bar.image = progress_bar.original_image.Scale(progress_box_width, progress_box_height);
  148.   progress_bar.sprite.SetImage(progress_bar.image);
  149. }
  150.  
  151. Plymouth.SetQuitFunction(quit_callback);
  152.  
  153. undBottomColor(0, 0, 0);
  154.  
  155. # screen width logo image was made to look best on
  156. logo_image_original_screen_width = 1024;
  157. logo_scale_factor = screen_width / logo_image_original_screen_width;
  158.  
  159. #logo.image = Image("special://logo");
  160. logo.original_image = Image ("crunchbang-logo.png");
  161. logo_width = logo.original_image.GetWidth() * logo_scale_factor;
  162. logo_height = logo.original_image.GetHeight() * logo_scale_factor;
  163. logo.image = logo.original_image.Scale(logo_width, logo_height);
  164. logo.sprite = Sprite(logo.image);
  165. logo.opacity_angle = 0;
  166.  
  167.  
  168. fun refresh_callback ()
  169.   {
  170.     if (status == "normal")
  171.       {
  172.         logo.opacity_angle += ((2 * 3.14) / 50) * 0.5;  # 0.5 HZ
  173.         min_opacity = 0.3;
  174.         opacity = (Math.Cos(logo.opacity_angle) + 1) / 2;
  175.         opacity *= 1 - min_opacity;
  176.         opacity += min_opacity;
  177.         logo.sprite.SetX (Window.GetX() + screen_width  / 2 - logo_width  / 2);
  178.         logo.sprite.SetY (Window.GetY() + screen_height / 2 - logo_height / 2);
  179.         logo.sprite.SetOpacity (opacity);
  180.       }
  181.     else
  182.       {
  183.         logo.sprite.SetX (0);
  184.         logo.sprite.SetY (0);
  185.         logo.sprite.SetOpacity (1);
  186.       }
  187.   }
  188.  
  189. Plymouth.SetRefreshFunction (refresh_callback);
  190.  
  191. status = "normal";
  192.  
  193. #----------------------------------------- Progress Bar --------------------------------
  194. progress_box_height = (logo_height * 0.1);
  195. progress_box_width = (screen_width * 0.4);
  196.  
  197. progress_box.original_image = Image("progress_box.png");
  198. progress_box.image = progress_box.original_image.Scale(progress_box_width, progress_box_height);
  199. progress_box.sprite = Sprite(progress_box.image);
  200.  
  201. progress_box.x = Window.GetX() + screen_width / 2 - progress_box_width / 2;
  202. progress_box.y = Window.GetY() + screen_height / 2 + logo_height / 2 + progress_box_height * 5;
  203. progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0);
  204.  
  205. progress_bar.original_image = Image("progress_bar.png");
  206. progress_bar.image = progress_bar.original_image.Scale(0, progress_box_height);
  207. progress_bar.sprite = Sprite();
  208.  
  209. progress_bar.x = progress_box.x;
  210. progress_bar.y = progress_box.y;
  211. progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1);
  212.  
  213. # "progress * 3" for bar width is a hack which should be unnecessary
  214. fun progress_callback (duration, progress)
  215.   {
  216. # I don't understand the purpose of this line, but changed it anyway
  217. #    if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress))
  218.     if (progress_bar.image.GetWidth () != Math.Int (progress_box_width * progress))
  219.       {
  220.         progress_bar.image = progress_bar.original_image.Scale(progress_box_width * progress * 3, progress_box_height);
  221.         progress_bar.sprite.SetImage (progress_bar.image);
  222.       }
  223.   }
  224.  
  225. Plymouth.SetBootProgressFunction(progress_callback);
  226.  
  227. #----------------------------------------- Status Update --------------------------------
  228.  
  229. NUM_SCROLL_LINES = 5;
  230. LINE_WIDTH = 55;
  231. # width of one character
  232. CHAR_WIDTH = 7;
  233. # height of one character
  234. CHAR_HEIGHT = 10;
  235.  
  236. fun StringLength(string) {
  237.   index = 0;
  238.   str = String(string);
  239.   while(str.CharAt(index)) index++;
  240.   return index;
  241. }
  242.  
  243. // Initialising text images and their positions
  244. // 20 is the height (including line spacing) of each line
  245. for (i=0; i < NUM_SCROLL_LINES; i++) {
  246.   lines[i]= Image.Text("");
  247.   message_sprite[i] = Sprite();
  248.   message_sprite[i].SetX (Window.GetX() + (screen_width / 2 ) - (LINE_WIDTH * CHAR_WIDTH / 2));
  249.   message_sprite[i].SetY (Window.GetY() + (screen_height / 2) + (logo_height /2) +(logo_height * 1.2)+ (i * CHAR_HEIGHT * 2) );
  250.   message_sprite[i].SetZ (10000);
  251. }
  252.  
  253.  
  254. fun scroll_message_callback(text) {
  255.  
  256.    // Truncate the message if too long
  257.    if (StringLength(text) > LINE_WIDTH) {
  258.      text = text.SubString(0, LINE_WIDTH - 3);
  259.      text += "...";
  260.    }
  261.  
  262.    // Shift messages one up
  263.    for (i = 0; i < NUM_SCROLL_LINES - 1; i++) {
  264.      lines[i] = lines[i+1];
  265.    }
  266.  
  267.    // Create the image for the latest message
  268. #  original script had "lines[i]"   
  269.    lines[4] = Image.Text( text, 0.5, 0.5, 0.5);
  270.  
  271.    // Re-allocate the text images to sprites
  272.    for (i = 0; i < NUM_SCROLL_LINES; i++) {
  273.      message_sprite[i].SetImage(lines[i]);
  274.    }
  275. }
  276.  
  277. Plymouth.SetUpdateStatusFunction(scroll_message_callback);
  278.  
  279. # messages get added to updates
  280. Plymouth.SetMessageFunction(scroll_message_callback);
  281.  
  282. #----------------------------------------- Quit --------------------------------
  283.  
  284. fun quit_callback ()
  285. {
  286.   logo.sprite.SetOpacity (1);
  287.   progress_bar.image = progress_bar.original_image.Scale(progress_box_width, progress_box_height);
  288.   progress_bar.sprite.SetImage(progress_bar.image);
  289. }
  290.  
  291. Plymouth.SetQuitFunction(quit_callback);

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me