# This is a modified version of the example plymouth plugin script screen_width = Window.GetWidth(); screen_height = Window.GetHeight(); Window.SetBackgroundTopColor(0, 0, 0); Window.SetBackgroundBottomColor(0, 0, 0); # screen width that logo image was made to look best on logo_image_original_screen_width = 1024; # just a guess logo_scale_factor = screen_width / logo_image_original_screen_width; #logo.image = Image("special://logo"); logo.original_image = Image ("crunchbang-logo.png"); logo_width = logo.original_image.GetWidth() * logo_scale_factor; logo_height = logo.original_image.GetHeight() * logo_scale_factor; logo.image = logo.original_image.Scale(logo_width, logo_height); logo.sprite = Sprite(logo.image); logo.opacity_angle = 0; fun refresh_callback () { if (status == "normal") { logo.opacity_angle += ((2 * 3.14) / 50) * 0.5; # 0.5 HZ min_opacity = 0.3; opacity = (Math.Cos(logo.opacity_angle) + 1) / 2; opacity *= 1 - min_opacity; opacity += min_opacity; logo.sprite.SetX (Window.GetX() + screen_width / 2 - logo_width / 2); logo.sprite.SetY (Window.GetY() + screen_height / 2 - logo_height / 2); logo.sprite.SetOpacity (opacity); } else { logo.sprite.SetX (0); logo.sprite.SetY (0); logo.sprite.SetOpacity (1); } } Plymouth.SetRefreshFunction (refresh_callback); status = "normal"; #----------------------------------------- Progress Bar -------------------------------- progress_box_height = (logo_height * 0.1); progress_box_width = (screen_width * 0.4); progress_box.original_image = Image("progress_box.png"); progress_box.image = progress_box.original_image.Scale(progress_box_width, progress_box_height); progress_box.sprite = Sprite(progress_box.image); progress_box.x = Window.GetX() + screen_width / 2 - progress_box_width / 2; progress_box.y = Window.GetY() + screen_height / 2 + logo_height / 2 + progress_box_height * 5; progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); progress_bar.original_image = Image("progress_bar.png"); progress_bar.image = progress_bar.original_image.Scale(0, progress_box_height); progress_bar.sprite = Sprite(); progress_bar.x = progress_box.x; progress_bar.y = progress_box.y; progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); # "progress * 2" for bar width is a hack which should be unnecessary fun progress_callback (duration, progress) { # I don't understand the purpose of this line, but changed it anyway # if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) if (progress_bar.image.GetWidth () != Math.Int (progress_box_width * progress)) { progress_bar.image = progress_bar.original_image.Scale(progress_box_width * progress * 2, progress_box_height); progress_bar.sprite.SetImage (progress_bar.image); } } Plymouth.SetBootProgressFunction(progress_callback); #----------------------------------------- Display Messages -------------------------------- NUM_SCROLL_LINES = 5; LINE_WIDTH = 55; # width of one character CHAR_WIDTH = 7; # are we using a fixed-width font? # height of one character CHAR_HEIGHT = 10; msg_color = [0.5,0.5,0.5]; # msg_color is array fun update_status_callback(sta) { if (sta == "failed") msg_color = [1,0,0]; if (sta == "warning") msg_color = [0.8,0.8,0]; if (sta == "normal") msg_color = [0.5,0.5,0.5]; } fun StringLength(string) { index = 0; str = String(string); while(str.CharAt(index)) index++; return index; } // Initialising text images and their positions # CHAR_HEIGHT * 2 is the height (including line spacing) of each line for (i=0; i < NUM_SCROLL_LINES; i++) { lines[i]= Image.Text(""); message_sprite[i] = Sprite(); message_sprite[i].SetX (Window.GetX() + (screen_width / 2 ) - (LINE_WIDTH * CHAR_WIDTH / 2)); message_sprite[i].SetY (Window.GetY() + (screen_height / 2) + (logo_height /2) +(logo_height * 1.2)+ (i * CHAR_HEIGHT * 2) ); message_sprite[i].SetZ (10000); } pretext = String(""); fun scroll_message_callback(text) { nobreak = 0; if (text.CharAt(0) == ">") { # "no linebreak" flag, like "-n" text = text.SubString(1, StringLength(text)); # remove ">" at front nobreak = 1; } if (pretext == "") { if (nobreak == 1) pretext = text; // Truncate the message if too long if (StringLength(text) > LINE_WIDTH) { text = text.SubString(0, LINE_WIDTH - 3); text += "..."; } // Shift messages one up for (i = 0; i < NUM_SCROLL_LINES - 1; i++) { lines[i] = lines[i+1]; } } else { # the previous message was flagged to have no linebreak // Truncate the message if too long if (StringLength(text) > LINE_WIDTH - 5) { # leave min. 5 for pretext text = text.SubString(0, LINE_WIDTH - 8); text += "..."; } # Truncate the previous message if too long if (StringLength(pretext) > (LINE_WIDTH - StringLength(text))) { pretext = pretext.SubString(0, LINE_WIDTH - StringLength(text) - 3); pretext += "..."; } text = pretext + text; if (nobreak == 1) pretext = text; else pretext = ""; } // Create the image for the latest message lines[NUM_SCROLL_LINES - 1] = Image.Text( text, msg_color[0], msg_color[1], msg_color[2]); // Re-allocate the text images to sprites for (i = 0; i < NUM_SCROLL_LINES; i++) { message_sprite[i].SetImage(lines[i]); } } Plymouth.SetUpdateStatusFunction(update_status_callback); Plymouth.SetMessageFunction(scroll_message_callback); #----------------------------------------- Quit -------------------------------- fun quit_callback () { logo.sprite.SetOpacity (1); progress_bar.image = progress_bar.original_image.Scale(progress_box_width, progress_box_height); progress_bar.sprite.SetImage(progress_bar.image); } Plymouth.SetQuitFunction(quit_callback);