diff --git a/boot/plymouth/chandra/chandra.plymouth b/boot/plymouth/chandra/chandra.plymouth new file mode 100644 index 0000000..a619050 --- /dev/null +++ b/boot/plymouth/chandra/chandra.plymouth @@ -0,0 +1,8 @@ +[Plymouth Theme] +Name=Chandra +Description=The Chandra moon over a boot progress bar +ModuleName=script + +[script] +ImageDir=/usr/share/plymouth/themes/chandra +ScriptFile=/usr/share/plymouth/themes/chandra/chandra.script diff --git a/boot/plymouth/chandra/chandra.script b/boot/plymouth/chandra/chandra.script new file mode 100644 index 0000000..f303c4b --- /dev/null +++ b/boot/plymouth/chandra/chandra.script @@ -0,0 +1,93 @@ +# Chandra boot splash: the moon, and a progress bar under it while booting. +# +# Plymouth estimates the progress from how long the last boot took (/var/lib/plymouth/boot-duration; +# 60 s until it has seen one boot). The bar eases towards that estimate and never moves backwards. + +Window.SetBackgroundTopColor(0.086, 0.129, 0.243); # #16213e +Window.SetBackgroundBottomColor(0.043, 0.063, 0.125); # #0b1020 + +center_x = Window.GetX() + Window.GetWidth() / 2; +center_y = Window.GetY() + Window.GetHeight() * 0.44; + +# The art is sized for a 1080 px wide panel; scale it on anything else. +art_scale = Window.GetWidth() / 1080; +if (Window.GetHeight() < Window.GetWidth()) art_scale = Window.GetHeight() / 1080; + +fun load(name) { + local.image = Image(name); + if (art_scale == 1) return image; + return image.Scale(Math.Int(image.GetWidth() * art_scale), Math.Int(image.GetHeight() * art_scale)); +} + +moon = load("moon.png"); +moon_sprite = Sprite(moon); +moon_sprite.SetPosition(Math.Int(center_x - moon.GetWidth() / 2), Math.Int(center_y - moon.GetHeight() / 2), 1); + +track = load("track.png"); +fill = load("fill.png"); +bar_x = Math.Int(center_x - track.GetWidth() / 2); +bar_y = Math.Int(center_y + moon.GetHeight() / 2 + 120 * art_scale); + +mode = Plymouth.GetMode(); +has_bar = mode == "boot"; + +if (has_bar) { + track_sprite = Sprite(track); + track_sprite.SetPosition(bar_x, bar_y, 1); + fill_sprite = Sprite(); + fill_sprite.SetPosition(bar_x, bar_y, 2); +} + +target = 0; +shown = 0; +drawn = 0; + +fun draw_bar() { + if (!has_bar) return; + local.width = Math.Int(fill.GetWidth() * shown); + # Redraw only when the bar grows by a pixel; narrower than its rounded cap it isn't drawn. + if (width <= drawn || width < fill.GetHeight()) return; + global.drawn = width; + fill_sprite.SetImage(fill.Crop(0, 0, width, fill.GetHeight())); +} + +fun progress_callback(duration, progress) { + if (progress > 1) progress = 1; + if (progress > target) global.target = progress; +} +Plymouth.SetBootProgressFunction(progress_callback); + +phase = 0; +ticks = 0; +fun refresh_callback() { + if (shown < target) { + global.shown = shown + (target - shown) * 0.08; + draw_bar(); + } + # A slow breath, 12 times a second: the panel is drawn by the CPU. + global.ticks = ticks + 1; + if (ticks >= 4) { + global.ticks = 0; + global.phase = phase + 0.10; + moon_sprite.SetOpacity(0.86 + 0.14 * Math.Cos(phase)); + } +} +Plymouth.SetRefreshFunction(refresh_callback); + +# The session is about to take the screen: finish the bar. +fun quit_callback() { + global.target = 1; + global.shown = 1; + draw_bar(); + moon_sprite.SetOpacity(1); +} +Plymouth.SetQuitFunction(quit_callback); + +# fsck, emergency mode and the like. +message_sprite = Sprite(); +fun message_callback(text) { + local.image = Image.Text(text, 0.78, 0.84, 1); + message_sprite.SetImage(image); + message_sprite.SetPosition(Math.Int(center_x - image.GetWidth() / 2), bar_y + Math.Int(60 * art_scale), 3); +} +Plymouth.SetMessageFunction(message_callback); diff --git a/boot/plymouth/chandra/fill.png b/boot/plymouth/chandra/fill.png new file mode 100644 index 0000000..f88ba02 Binary files /dev/null and b/boot/plymouth/chandra/fill.png differ diff --git a/boot/plymouth/chandra/moon.png b/boot/plymouth/chandra/moon.png new file mode 100644 index 0000000..8712ef8 Binary files /dev/null and b/boot/plymouth/chandra/moon.png differ diff --git a/boot/plymouth/chandra/track.png b/boot/plymouth/chandra/track.png new file mode 100644 index 0000000..090c796 Binary files /dev/null and b/boot/plymouth/chandra/track.png differ diff --git a/boot/plymouth/fill.svg b/boot/plymouth/fill.svg new file mode 100644 index 0000000..e4da27f --- /dev/null +++ b/boot/plymouth/fill.svg @@ -0,0 +1,4 @@ + + + + diff --git a/boot/plymouth/moon.svg b/boot/plymouth/moon.svg new file mode 100644 index 0000000..b872121 --- /dev/null +++ b/boot/plymouth/moon.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/boot/plymouth/render.sh b/boot/plymouth/render.sh new file mode 100755 index 0000000..87cee69 --- /dev/null +++ b/boot/plymouth/render.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# Render the theme's PNGs from the SVGs beside this script (needs rsvg-convert). +set -e +cd "$(dirname "$0")" +for f in moon track fill; do rsvg-convert "$f.svg" -o "chandra/$f.png"; done diff --git a/boot/plymouth/track.svg b/boot/plymouth/track.svg new file mode 100644 index 0000000..0049944 --- /dev/null +++ b/boot/plymouth/track.svg @@ -0,0 +1 @@ +