mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
Update Plymouth theme to enable smoother progress bar (#3661)
* Update Plymouth theme to enable smoother progress bar * Fix migration --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
co-authored by
David Heinemeier Hansson
parent
e8b1b4649f
commit
a700806f91
@@ -3,7 +3,7 @@
|
|||||||
# omarchy:summary=Overwrite the user config for the Plymouth drive decryption and boot sequence with the Omarchy default and rebuild it.
|
# omarchy:summary=Overwrite the user config for the Plymouth drive decryption and boot sequence with the Omarchy default and rebuild it.
|
||||||
# omarchy:requires-sudo=true
|
# omarchy:requires-sudo=true
|
||||||
|
|
||||||
sudo cp ~/.local/share/omarchy/default/plymouth/* /usr/share/plymouth/themes/omarchy/
|
sudo cp -r ~/.local/share/omarchy/default/plymouth/* /usr/share/plymouth/themes/omarchy/
|
||||||
sudo plymouth-set-default-theme omarchy
|
sudo plymouth-set-default-theme omarchy
|
||||||
|
|
||||||
if command -v limine-mkinitcpio &>/dev/null; then
|
if command -v limine-mkinitcpio &>/dev/null; then
|
||||||
|
|||||||
+136
-158
@@ -1,116 +1,105 @@
|
|||||||
# Omarchy Plymouth Theme Script
|
# Omarchy Plymouth Theme Script
|
||||||
|
|
||||||
Window.SetBackgroundTopColor(0.101, 0.105, 0.149);
|
Window.SetBackgroundTopColor(0.101, 0.105, 0.149);
|
||||||
Window.SetBackgroundBottomColor(0.101, 0.105, 0.149);
|
Window.SetBackgroundBottomColor(0.101, 0.105, 0.149);
|
||||||
|
|
||||||
logo.image = Image("logo.png");
|
logo.image = Image("logo.png");
|
||||||
logo.sprite = Sprite(logo.image);
|
logo.sprite = Sprite(logo.image);
|
||||||
logo.sprite.SetX (Window.GetWidth() / 2 - logo.image.GetWidth() / 2);
|
logo.sprite.SetX(Window.GetWidth() / 2 - logo.image.GetWidth() / 2);
|
||||||
logo.sprite.SetY (Window.GetHeight() / 2 - logo.image.GetHeight() / 2);
|
logo.sprite.SetY(Window.GetHeight() / 2 - logo.image.GetHeight() / 2);
|
||||||
logo.sprite.SetOpacity (1);
|
logo.sprite.SetOpacity(1);
|
||||||
|
|
||||||
# Use these to adjust the progress bar timing
|
# 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_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
|
global.fake_progress_duration = 15.0; # Duration in seconds to reach limit
|
||||||
|
|
||||||
# Progress bar animation variables
|
# Progress bar animation variables
|
||||||
|
global.animation_frame = 0;
|
||||||
global.fake_progress = 0.0;
|
global.fake_progress = 0.0;
|
||||||
global.real_progress = 0.0;
|
global.real_progress = 0.0;
|
||||||
global.fake_progress_active = 0; # 0 / 1 boolean
|
global.fake_progress_active = 0;
|
||||||
global.animation_frame = 0;
|
global.fake_progress_start_time = 0.0; # Track when fake progress started
|
||||||
global.fake_progress_start_time = 0; # Track when fake progress started
|
|
||||||
global.password_shown = 0; # Track if password dialog has been shown
|
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
|
global.max_progress = 0.0; # Track the maximum progress reached to prevent backwards movement
|
||||||
|
|
||||||
fun refresh_callback ()
|
fun refresh_callback() {
|
||||||
{
|
global.animation_frame++;
|
||||||
global.animation_frame++;
|
|
||||||
|
# Animate fake progress to limit over time with easing
|
||||||
# Animate fake progress to limit over time with easing
|
if (global.fake_progress_active == 1) {
|
||||||
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 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;
|
||||||
# Calculate linear progress ratio (0 to 1) based on time
|
if (time_ratio > 1.0) time_ratio = 1.0;
|
||||||
time_ratio = elapsed_time / global.fake_progress_duration;
|
|
||||||
if (time_ratio > 1.0)
|
# Apply easing curve: ease-out quadratic
|
||||||
time_ratio = 1.0;
|
# Formula: 1 - (1 - x)^2
|
||||||
|
eased_ratio = 1 - ((1 - time_ratio) * (1 - time_ratio));
|
||||||
# Apply easing curve: ease-out quadratic
|
|
||||||
# Formula: 1 - (1 - x)^2
|
# Calculate fake progress based on eased ratio
|
||||||
eased_ratio = 1 - ((1 - time_ratio) * (1 - time_ratio));
|
global.fake_progress = eased_ratio * global.fake_progress_limit;
|
||||||
|
|
||||||
# Calculate fake progress based on eased ratio
|
# Update progress bar with fake progress
|
||||||
global.fake_progress = eased_ratio * global.fake_progress_limit;
|
update_progress_bar(global.fake_progress);
|
||||||
|
|
||||||
# Update progress bar with fake progress
|
|
||||||
update_progress_bar(global.fake_progress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Plymouth.SetRefreshFunction(refresh_callback);
|
||||||
Plymouth.SetRefreshFunction (refresh_callback);
|
|
||||||
|
|
||||||
#----------------------------------------- Helper Functions --------------------------------
|
#----------------------------------------- Helper Functions --------------------------------
|
||||||
|
|
||||||
fun update_progress_bar(progress)
|
fun update_progress_bar(progress) {
|
||||||
{
|
# Only update if progress is moving forward
|
||||||
# Only update if progress is moving forward
|
if (progress > global.max_progress) {
|
||||||
if (progress > global.max_progress)
|
global.max_progress = 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()
|
width = Math.Int(progress_bar.original_image.GetWidth() * progress);
|
||||||
{
|
if (width < 1) width = 1; # Ensure minimum width of 1 pixel
|
||||||
progress_box.sprite.SetOpacity(1);
|
|
||||||
progress_bar.sprite.SetOpacity(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hide_progress_bar()
|
progress_bar.image = progress_bar.original_image.Scale(width, progress_bar.original_image.GetHeight());
|
||||||
{
|
progress_bar.sprite.SetImage(progress_bar.image);
|
||||||
progress_box.sprite.SetOpacity(0);
|
|
||||||
progress_bar.sprite.SetOpacity(0);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun show_password_dialog()
|
fun show_progress_bar() {
|
||||||
{
|
progress_box.sprite.SetOpacity(1);
|
||||||
lock.sprite.SetOpacity(1);
|
progress_bar.sprite.SetOpacity(1);
|
||||||
entry.sprite.SetOpacity(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun hide_password_dialog()
|
fun hide_progress_bar() {
|
||||||
{
|
progress_box.sprite.SetOpacity(0);
|
||||||
lock.sprite.SetOpacity(0);
|
progress_bar.sprite.SetOpacity(0);
|
||||||
entry.sprite.SetOpacity(0);
|
}
|
||||||
for (index = 0; bullet.sprites[index]; index++)
|
|
||||||
bullet.sprites[index].SetOpacity(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
fun start_fake_progress()
|
fun show_password_dialog() {
|
||||||
{
|
lock.sprite.SetOpacity(1);
|
||||||
# Don't reset if we already have progress
|
entry.sprite.SetOpacity(1);
|
||||||
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()
|
fun hide_password_dialog() {
|
||||||
{
|
lock.sprite.SetOpacity(0);
|
||||||
global.fake_progress_active = 0;
|
entry.sprite.SetOpacity(0);
|
||||||
|
|
||||||
|
for (index = 0; bullet.sprites[index]; index++) {
|
||||||
|
bullet.sprites[index].SetOpacity(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun start_fake_progress() {
|
||||||
|
global.fake_progress_active = 1;
|
||||||
|
|
||||||
|
# Reset fake progress
|
||||||
|
global.animation_frame = 0;
|
||||||
|
global.max_progress = 0.0;
|
||||||
|
global.fake_progress = 0.0;
|
||||||
|
global.fake_progress_start_time = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stop_fake_progress() {
|
||||||
|
global.fake_progress_active = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#----------------------------------------- Dialogue --------------------------------
|
#----------------------------------------- Dialogue --------------------------------
|
||||||
|
|
||||||
@@ -119,7 +108,7 @@ entry.image = Image("entry.png");
|
|||||||
bullet.image = Image("bullet.png");
|
bullet.image = Image("bullet.png");
|
||||||
|
|
||||||
entry.sprite = Sprite(entry.image);
|
entry.sprite = Sprite(entry.image);
|
||||||
entry.x = Window.GetWidth()/2 - entry.image.GetWidth() / 2;
|
entry.x = Window.GetWidth() / 2 - entry.image.GetWidth() / 2;
|
||||||
entry.y = logo.sprite.GetY() + logo.image.GetHeight() + 40;
|
entry.y = logo.sprite.GetY() + logo.image.GetHeight() + 40;
|
||||||
entry.sprite.SetPosition(entry.x, entry.y, 10001);
|
entry.sprite.SetPosition(entry.x, entry.y, 10001);
|
||||||
entry.sprite.SetOpacity(0);
|
entry.sprite.SetOpacity(0);
|
||||||
@@ -133,65 +122,60 @@ lock_width = 84 * lock_scale;
|
|||||||
scaled_lock = lock.image.Scale(lock_width, lock_height);
|
scaled_lock = lock.image.Scale(lock_width, lock_height);
|
||||||
lock.sprite = Sprite(scaled_lock);
|
lock.sprite = Sprite(scaled_lock);
|
||||||
lock.x = entry.x - lock_width - 15;
|
lock.x = entry.x - lock_width - 15;
|
||||||
lock.y = entry.y + entry.image.GetHeight()/2 - lock_height/2;
|
lock.y = entry.y + entry.image.GetHeight() / 2 - lock_height / 2;
|
||||||
lock.sprite.SetPosition(lock.x, lock.y, 10001);
|
lock.sprite.SetPosition(lock.x, lock.y, 10001);
|
||||||
lock.sprite.SetOpacity(0);
|
lock.sprite.SetOpacity(0);
|
||||||
|
|
||||||
# Bullet array
|
# Bullet array
|
||||||
bullet.sprites = [];
|
bullet.sprites = [];
|
||||||
|
|
||||||
fun display_normal_callback ()
|
fun display_normal_callback() {
|
||||||
{
|
hide_password_dialog();
|
||||||
hide_password_dialog();
|
|
||||||
|
# Get current mode
|
||||||
# Get current mode
|
mode = Plymouth.GetMode();
|
||||||
mode = Plymouth.GetMode();
|
|
||||||
|
# Only show progress bar for boot and resume modes
|
||||||
# Only show progress bar for boot and resume modes
|
if ((mode == "boot" || mode == "resume") && global.password_shown == 1) {
|
||||||
if ((mode == "boot" || mode == "resume") && global.password_shown == 1)
|
show_progress_bar();
|
||||||
{
|
start_fake_progress();
|
||||||
show_progress_bar();
|
}
|
||||||
start_fake_progress();
|
}
|
||||||
}
|
|
||||||
|
fun display_password_callback(prompt, bullets) {
|
||||||
|
global.password_shown = 1; # Mark that password dialog has been shown
|
||||||
|
|
||||||
|
# Stop fake progress when password dialog appears
|
||||||
|
stop_fake_progress();
|
||||||
|
hide_progress_bar();
|
||||||
|
show_password_dialog();
|
||||||
|
|
||||||
|
# Clear all bullets first
|
||||||
|
for (index = 0; bullet.sprites[index]; index++) {
|
||||||
|
bullet.sprites[index].SetOpacity(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fun display_password_callback (prompt, bullets)
|
# Create and show bullets for current password (max 21)
|
||||||
{
|
max_bullets = 21;
|
||||||
global.password_shown = 1; # Mark that password dialog has been shown
|
bullets_to_show = bullets;
|
||||||
|
if (bullets_to_show > max_bullets) {
|
||||||
# Reset progress when password dialog appears
|
bullets_to_show = max_bullets;
|
||||||
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 7x7 pixels
|
|
||||||
scaled_bullet = bullet.image.Scale(7, 7);
|
|
||||||
bullet.sprites[index] = Sprite(scaled_bullet);
|
|
||||||
bullet.x = entry.x + 20 + index * (7 + 5);
|
|
||||||
bullet.y = entry.y + entry.image.GetHeight() / 2 - 3.5;
|
|
||||||
bullet.sprites[index].SetPosition(bullet.x, bullet.y, 10002);
|
|
||||||
}
|
|
||||||
bullet.sprites[index].SetOpacity(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (index = 0; index < bullets_to_show; index++) {
|
||||||
|
if (!bullet.sprites[index]) {
|
||||||
|
# Scale bullet image to 7x7 pixels
|
||||||
|
scaled_bullet = bullet.image.Scale(7, 7);
|
||||||
|
bullet.sprites[index] = Sprite(scaled_bullet);
|
||||||
|
bullet.x = entry.x + 20 + index * (7 + 5);
|
||||||
|
bullet.y = entry.y + entry.image.GetHeight() / 2 - 3.5;
|
||||||
|
bullet.sprites[index].SetPosition(bullet.x, bullet.y, 10002);
|
||||||
|
}
|
||||||
|
|
||||||
|
bullet.sprites[index].SetOpacity(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Plymouth.SetDisplayNormalFunction(display_normal_callback);
|
Plymouth.SetDisplayNormalFunction(display_normal_callback);
|
||||||
Plymouth.SetDisplayPasswordFunction(display_password_callback);
|
Plymouth.SetDisplayPasswordFunction(display_password_callback);
|
||||||
|
|
||||||
@@ -214,44 +198,38 @@ progress_bar.y = progress_box.y + (progress_box.image.GetHeight() - progress_bar
|
|||||||
progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1);
|
progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1);
|
||||||
progress_bar.sprite.SetOpacity(0);
|
progress_bar.sprite.SetOpacity(0);
|
||||||
|
|
||||||
fun progress_callback (duration, progress)
|
fun progress_callback(duration, progress) {
|
||||||
{
|
# Track when fake progress starts
|
||||||
global.real_progress = progress;
|
# Needed because duration and progress freeze during drive decryption
|
||||||
|
if (global.fake_progress_start_time == 0.0) {
|
||||||
# If real progress is above limit, stop fake progress and use real progress
|
global.fake_progress_start_time = duration;
|
||||||
if (progress > global.fake_progress_limit)
|
|
||||||
{
|
|
||||||
stop_fake_progress();
|
|
||||||
update_progress_bar(progress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Plymouth.SetBootProgressFunction(progress_callback);
|
global.real_progress = progress;
|
||||||
|
|
||||||
#----------------------------------------- Quit --------------------------------
|
# Use real progress once its unfrozen and exceeds fake progress
|
||||||
|
if (duration > global.fake_progress_start_time && progress > global.fake_progress) {
|
||||||
fun quit_callback ()
|
stop_fake_progress();
|
||||||
{
|
update_progress_bar(progress);
|
||||||
logo.sprite.SetOpacity (1);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Plymouth.SetQuitFunction(quit_callback);
|
Plymouth.SetBootProgressFunction(progress_callback);
|
||||||
|
|
||||||
#----------------------------------------- Message --------------------------------
|
#----------------------------------------- Message --------------------------------
|
||||||
|
|
||||||
message_sprite = Sprite();
|
message_sprite = Sprite();
|
||||||
message_sprite.SetPosition(10, 10, 10000);
|
message_sprite.SetPosition(10, 10, 10000);
|
||||||
|
|
||||||
fun display_message_callback (text)
|
fun display_message_callback(text) {
|
||||||
{
|
message = Image.Text(text, 1, 1, 1);
|
||||||
my_image = Image.Text(text, 1, 1, 1);
|
message_sprite.SetImage(message);
|
||||||
message_sprite.SetImage(my_image);
|
message_sprite.SetOpacity(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hide_message_callback (text)
|
fun hide_message_callback(text) {
|
||||||
{
|
|
||||||
message_sprite.SetOpacity(0);
|
message_sprite.SetOpacity(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plymouth.SetDisplayMessageFunction (display_message_callback);
|
Plymouth.SetDisplayMessageFunction(display_message_callback);
|
||||||
Plymouth.SetHideMessageFunction (hide_message_callback);
|
Plymouth.SetHideMessageFunction(hide_message_callback);
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
echo "Update Plymouth theme for a smoother progress bar animation"
|
||||||
|
omarchy-refresh-plymouth
|
||||||
Reference in New Issue
Block a user