# Arch Linux Plymouth Theme Script Window.SetBackgroundTopColor(0, 0, 0); Window.SetBackgroundBottomColor(0, 0, 0); logo.original_image = Image("logo.png"); # Scale logo to at most 40% of screen height logo.max_height = Math.Int(Window.GetHeight() * 0.40); if (logo.original_image.GetHeight() > logo.max_height) { logo.scale = logo.max_height / logo.original_image.GetHeight(); logo.image = logo.original_image.Scale( Math.Int(logo.original_image.GetWidth() * logo.scale), logo.max_height ); } else { logo.image = logo.original_image; } logo.sprite = Sprite(logo.image); # Center the logo during boot logo.normal_x = Window.GetWidth() / 2 - logo.image.GetWidth() / 2; logo.normal_y = Window.GetHeight() / 2 - logo.image.GetHeight() / 2; logo.sprite.SetPosition(logo.normal_x, logo.normal_y, 1); logo.sprite.SetOpacity(1); # Use these to adjust the progress bar timing global.fake_progress_limit = 0.7; # Target percentage for fake progress (0.0 to 1.0) global.fake_progress_duration = 15.0; # Duration in seconds to reach limit # Progress bar animation variables global.fake_progress = 0.0; global.real_progress = 0.0; global.fake_progress_active = 0; # 0 / 1 boolean global.animation_frame = 0; global.fake_progress_start_time = 0; # Track when fake progress started global.password_shown = 0; # Track if password dialog has been shown global.max_progress = 0.0; # Track the maximum progress reached to prevent backwards movement fun refresh_callback () { global.animation_frame++; # Animate fake progress to limit over time with easing if (global.fake_progress_active == 1) { # Calculate elapsed time since start elapsed_time = global.animation_frame / 50.0; # Convert frames to seconds (50 FPS) # Calculate linear progress ratio (0 to 1) based on time time_ratio = elapsed_time / global.fake_progress_duration; if (time_ratio > 1.0) time_ratio = 1.0; # Apply easing curve: ease-out quadratic # Formula: 1 - (1 - x)^2 eased_ratio = 1 - ((1 - time_ratio) * (1 - time_ratio)); # Calculate fake progress based on eased ratio global.fake_progress = eased_ratio * global.fake_progress_limit; # Update progress bar with fake progress update_progress_bar(global.fake_progress); } } Plymouth.SetRefreshFunction (refresh_callback); #----------------------------------------- Helper Functions -------------------------------- fun update_progress_bar(progress) { # Only update if progress is moving forward if (progress > global.max_progress) { global.max_progress = progress; width = Math.Int(progress_bar.original_image.GetWidth() * progress); if (width < 1) width = 1; # Ensure minimum width of 1 pixel progress_bar.image = progress_bar.original_image.Scale(width, progress_bar.original_image.GetHeight()); progress_bar.sprite.SetImage(progress_bar.image); } } fun show_progress_bar() { progress_box.sprite.SetOpacity(1); progress_bar.sprite.SetOpacity(1); } fun hide_progress_bar() { progress_box.sprite.SetOpacity(0); progress_bar.sprite.SetOpacity(0); } fun show_password_dialog() { entry.sprite.SetOpacity(1); } fun hide_password_dialog() { entry.sprite.SetOpacity(0); for (index = 0; bullet.sprites[index]; index++) bullet.sprites[index].SetOpacity(0); } fun start_fake_progress() { # Don't reset if we already have progress if (global.max_progress == 0.0) { global.fake_progress = 0.0; global.real_progress = 0.0; update_progress_bar(0.0); } global.fake_progress_active = 1; global.animation_frame = 0; } fun stop_fake_progress() { global.fake_progress_active = 0; } #----------------------------------------- Dialogue -------------------------------- entry.image = Image("entry.png"); bullet.image = Image("bullet.png"); # Scale entry to 60% of its original size entry.scaled_image = entry.image.Scale( Math.Int(entry.image.GetWidth() * 0.6), Math.Int(entry.image.GetHeight() * 0.6) ); # Entry appears below the centered logo with a fixed gap dialog_gap = 32; entry.dialog_y = logo.normal_y + logo.image.GetHeight() + dialog_gap; # Safety cap: never push entry off screen entry.max_y = Window.GetHeight() - entry.scaled_image.GetHeight() - 20; if (entry.dialog_y > entry.max_y) entry.dialog_y = entry.max_y; entry.x = Window.GetWidth() / 2 - entry.scaled_image.GetWidth() / 2; entry.sprite = Sprite(entry.scaled_image); entry.sprite.SetPosition(entry.x, entry.dialog_y, 10001); entry.sprite.SetOpacity(0); # Bullet array bullet.sprites = []; fun display_normal_callback () { hide_password_dialog(); # Restore logo to center when back to normal boot screen logo.sprite.SetPosition(logo.normal_x, logo.normal_y, 1); # Get current mode mode = Plymouth.GetMode(); # Only show progress bar for boot and resume modes if ((mode == "boot" || mode == "resume") && global.password_shown == 1) { show_progress_bar(); start_fake_progress(); } } fun display_password_callback (prompt, bullets) { global.password_shown = 1; # Mark that password dialog has been shown # Keep logo at its normal centered position during unlock logo.sprite.SetPosition(logo.normal_x, logo.normal_y, 1); # Reset progress when password dialog appears stop_fake_progress(); hide_progress_bar(); global.max_progress = 0.0; global.fake_progress = 0.0; global.real_progress = 0.0; show_password_dialog(); # Clear all bullets first for (index = 0; bullet.sprites[index]; index++) bullet.sprites[index].SetOpacity(0); # Create and show bullets for current password (max 21) max_bullets = 21; bullets_to_show = bullets; if (bullets_to_show > max_bullets) bullets_to_show = max_bullets; for (index = 0; index < bullets_to_show; index++) { if (!bullet.sprites[index]) { # Scale bullet image to 6x6 pixels scaled_bullet = bullet.image.Scale(6, 6); bullet.sprites[index] = Sprite(scaled_bullet); bullet.x = entry.x + 12 + index * (6 + 4); bullet.y = entry.dialog_y + entry.scaled_image.GetHeight() / 2 - 3; bullet.sprites[index].SetPosition(bullet.x, bullet.y, 10002); } bullet.sprites[index].SetOpacity(1); } } Plymouth.SetDisplayNormalFunction(display_normal_callback); Plymouth.SetDisplayPasswordFunction(display_password_callback); #----------------------------------------- Progress Bar -------------------------------- progress_box.image = Image("progress_box.png"); progress_box.sprite = Sprite(progress_box.image); progress_box.x = Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; progress_box.y = logo.normal_y + logo.image.GetHeight() + 40; progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); progress_box.sprite.SetOpacity(0); progress_bar.original_image = Image("progress_bar.png"); progress_bar.sprite = Sprite(); progress_bar.image = progress_bar.original_image.Scale(1, progress_bar.original_image.GetHeight()); progress_bar.x = Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2; progress_bar.y = progress_box.y + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2; progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); progress_bar.sprite.SetOpacity(0); fun progress_callback (duration, progress) { global.real_progress = progress; # If real progress is above limit, stop fake progress and use real progress if (progress > global.fake_progress_limit) { stop_fake_progress(); update_progress_bar(progress); } } Plymouth.SetBootProgressFunction(progress_callback); #----------------------------------------- Quit -------------------------------- fun quit_callback () { logo.sprite.SetOpacity (1); } Plymouth.SetQuitFunction(quit_callback); #----------------------------------------- Message -------------------------------- message_sprite = Sprite(); message_sprite.SetPosition(10, 10, 10000); fun display_message_callback (text) { my_image = Image.Text(text, 1, 1, 1); message_sprite.SetImage(my_image); } fun hide_message_callback (text) { message_sprite.SetOpacity(0); } Plymouth.SetDisplayMessageFunction (display_message_callback); Plymouth.SetHideMessageFunction (hide_message_callback);