# 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 logo image was made to look best on logo_image_original_screen_width = 1024; 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 * 3" 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 * 3, progress_box_height); progress_bar.sprite.SetImage (progress_bar.image); } } Plymouth.SetBootProgressFunction(progress_callback); #----------------------------------------- Status Update -------------------------------- NUM_SCROLL_LINES = 5; LINE_WIDTH = 55; # width of one character CHAR_WIDTH = 7; # height of one character CHAR_HEIGHT = 10; fun StringLength(string) { index = 0; str = String(string); while(str.CharAt(index)) index++; return index; } // Initialising text images and their positions // 20 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); } fun scroll_message_callback(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]; } // Create the image for the latest message # original script had "lines[i]" lines[4] = Image.Text( text, 0.5, 0.5, 0.5); // Re-allocate the text images to sprites for (i = 0; i < NUM_SCROLL_LINES; i++) { message_sprite[i].SetImage(lines[i]); } } Plymouth.SetUpdateStatusFunction(scroll_message_callback); # messages get added to updates 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);