feat(plymouth): boot splash background follows the active palette
themes/engine/plymouth/nomarchy.script had `Window.SetBackgroundTopColor(0.101, 0.105, 0.149)` hardcoded — a Tokyo-Night-ish #1a1b26 — and nomarchy.plymouth had a matching `ConsoleLogBackgroundColor=0x1a1b26`. Both were frozen regardless of the active nomarchy.system.theme. Replaced the literals with placeholders (@BG_R@, @BG_G@, @BG_B@, @BG_HEX@) in the source files. themes/engine/plymouth.nix now reads the active palette via `nomarchyLib.getPalette config.nomarchy.system.theme`, converts palette.base00 into three 0.0–1.0 floats (Nix has no floating-point math, so `(byte * 1000) / 255` integer division formatted as `0.XXX`), and `sed`-substitutes both files during installPhase. Smoke-built the derivation against the default summer-night palette: $ cat .../nomarchy.script | grep BackgroundTopColor Window.SetBackgroundTopColor(0.176, 0.207, 0.231); $ cat .../nomarchy.plymouth | grep ConsoleLogBackgroundColor ConsoleLogBackgroundColor=0x2d353b Both match the expected byte→float conversion from base00=2d353b. Closes the "Plymouth theme variants per palette" Next-column item. `nix flake check --no-build` clean.
This commit is contained in:
@@ -1,6 +1,37 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
nomarchyLib = import ../../lib { inherit lib; };
|
||||||
|
palette = nomarchyLib.getPalette config.nomarchy.system.theme;
|
||||||
|
|
||||||
|
# Plymouth's Window.SetBackgroundTopColor takes three floats in 0.0–1.0;
|
||||||
|
# the .plymouth metadata's ConsoleLogBackgroundColor takes a 0xRRGGBB
|
||||||
|
# hex. Compute both from palette.base00 so the boot splash matches the
|
||||||
|
# rest of the active theme instead of staying frozen on the hardcoded
|
||||||
|
# Tokyo-Night-ish #1a1b26 it used to ship with.
|
||||||
|
hex = palette.base00;
|
||||||
|
rByte = lib.fromHexString (lib.substring 0 2 hex);
|
||||||
|
gByte = lib.fromHexString (lib.substring 2 2 hex);
|
||||||
|
bByte = lib.fromHexString (lib.substring 4 2 hex);
|
||||||
|
|
||||||
|
# byte → "0.XXX" decimal string. Nix has no floating-point math, so
|
||||||
|
# multiply first, integer-divide, then format. Plymouth tolerates more
|
||||||
|
# decimals than this (0.1019 etc.) but three digits matches the visual
|
||||||
|
# precision Plymouth renders at and keeps the substitution readable.
|
||||||
|
byteToFloat = n:
|
||||||
|
let
|
||||||
|
thousandths = (n * 1000) / 255;
|
||||||
|
s = toString thousandths;
|
||||||
|
padded =
|
||||||
|
if lib.stringLength s == 1 then "00${s}"
|
||||||
|
else if lib.stringLength s == 2 then "0${s}"
|
||||||
|
else s;
|
||||||
|
in "0.${padded}";
|
||||||
|
|
||||||
|
bgR = byteToFloat rByte;
|
||||||
|
bgG = byteToFloat gByte;
|
||||||
|
bgB = byteToFloat bByte;
|
||||||
|
|
||||||
nomarchy-plymouth = pkgs.stdenv.mkDerivation {
|
nomarchy-plymouth = pkgs.stdenv.mkDerivation {
|
||||||
pname = "nomarchy-plymouth";
|
pname = "nomarchy-plymouth";
|
||||||
version = "1.0";
|
version = "1.0";
|
||||||
@@ -10,8 +41,21 @@ let
|
|||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/share/plymouth/themes/nomarchy
|
mkdir -p $out/share/plymouth/themes/nomarchy
|
||||||
cp * $out/share/plymouth/themes/nomarchy/
|
cp * $out/share/plymouth/themes/nomarchy/
|
||||||
|
|
||||||
# Fix path in the plymouth file to point to the nix store
|
# Fix path in the plymouth file to point to the nix store
|
||||||
sed -i "s|/[a-z]*/share/plymouth/themes/nomarchy|$out/share/plymouth/themes/nomarchy|g" $out/share/plymouth/themes/nomarchy/nomarchy.plymouth
|
sed -i "s|/[a-z]*/share/plymouth/themes/nomarchy|$out/share/plymouth/themes/nomarchy|g" \
|
||||||
|
$out/share/plymouth/themes/nomarchy/nomarchy.plymouth
|
||||||
|
|
||||||
|
# Substitute the active theme's base00 in both the .script (RGB
|
||||||
|
# floats for the Window.SetBackground* calls) and the .plymouth
|
||||||
|
# metadata (0xRRGGBB for ConsoleLogBackgroundColor).
|
||||||
|
sed -i \
|
||||||
|
-e 's|@BG_R@|${bgR}|g' \
|
||||||
|
-e 's|@BG_G@|${bgG}|g' \
|
||||||
|
-e 's|@BG_B@|${bgB}|g' \
|
||||||
|
$out/share/plymouth/themes/nomarchy/nomarchy.script
|
||||||
|
sed -i 's|@BG_HEX@|${hex}|g' \
|
||||||
|
$out/share/plymouth/themes/nomarchy/nomarchy.plymouth
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ ModuleName=script
|
|||||||
[script]
|
[script]
|
||||||
ImageDir=/usr/share/plymouth/themes/nomarchy
|
ImageDir=/usr/share/plymouth/themes/nomarchy
|
||||||
ScriptFile=/usr/share/plymouth/themes/nomarchy/nomarchy.script
|
ScriptFile=/usr/share/plymouth/themes/nomarchy/nomarchy.script
|
||||||
ConsoleLogBackgroundColor=0x1a1b26
|
ConsoleLogBackgroundColor=0x@BG_HEX@
|
||||||
MonospaceFont=Cantarell 11
|
MonospaceFont=Cantarell 11
|
||||||
Font=Cantarell 11
|
Font=Cantarell 11
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Nomarchy Plymouth Theme Script
|
# Nomarchy Plymouth Theme Script
|
||||||
|
|
||||||
Window.SetBackgroundTopColor(0.101, 0.105, 0.149);
|
Window.SetBackgroundTopColor(@BG_R@, @BG_G@, @BG_B@);
|
||||||
Window.SetBackgroundBottomColor(0.101, 0.105, 0.149);
|
Window.SetBackgroundBottomColor(@BG_R@, @BG_G@, @BG_B@);
|
||||||
|
|
||||||
logo.image = Image("logo.png");
|
logo.image = Image("logo.png");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user