Allow using theme colours for Plymouth

There is now a choice to either follow the main theme or keep a black
background.

systemd-boot enables the black background by default, as it always has a
black background itself, and keeping the same colour throughout the
whole boot process looks cleaner than applying our theme at the first
opportunity.
This commit is contained in:
Daniel Thwaites 2022-10-06 12:19:25 +01:00
parent ee248692cb
commit 1d61691bf9
No known key found for this signature in database
GPG key ID: D8AFC4BF05670F9D
2 changed files with 27 additions and 2 deletions

View file

@ -18,6 +18,13 @@ let
cp ${config.lib.stylix.pixel "base01"} $themeDir/progress-bar.png
cp ${./theme.script} $themeDir/stylix.script
substituteInPlace $themeDir/stylix.script \
--replace "%BASE00%" "${
if config.stylix.targets.plymouth.blackBackground
then "0, 0, 0"
else "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}"
}" \
--replace "%BASE05%" "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}"
echo "
[Plymouth Theme]
@ -48,6 +55,18 @@ in {
sha256 = "SCuQlSPB14GFTq4XvExJ0QEuK2VIbrd5YYKHLRG/q5I=";
};
};
blackBackground = mkOption {
description = ''
Whether to use a black background rather than a theme colour.
This looks good in combination with systemd-boot, as it means that the
background colour doesn't change throughout the boot process.
'';
type = types.bool;
defaultText = literalDocBook "<literal>true</literal> if systemd-boot is enabled";
default = config.boot.loader.systemd-boot.enable;
};
};
config.boot.plymouth = mkIf config.stylix.targets.plymouth.enable {

View file

@ -3,6 +3,12 @@ center_y = Window.GetHeight() / 2;
baseline_y = (Window.GetHeight() / 3) * 2;
### BACKGROUND ###
Window.SetBackgroundTopColor(%BASE00%);
Window.SetBackgroundBottomColor(%BASE00%);
### LOGO ###
logo.original_image = Image("logo.png");
@ -60,13 +66,13 @@ Plymouth.SetBootProgressFunction(progress_callback);
prompt = null;
bullets = null;
bullet.image = Image.Text("•", 1, 1, 1);
bullet.image = Image.Text("•", %BASE05%);
fun password_callback (prompt_text, bullet_count) {
progress_background.sprite.SetOpacity(0);
progress_bar.sprite.SetOpacity(0);
prompt.image = Image.Text("Enter password", 1, 1, 1);
prompt.image = Image.Text("Enter password", %BASE05%);
prompt.sprite = Sprite(prompt.image);
prompt.sprite.SetPosition(
center_x - (prompt.image.GetWidth() / 2),