user/catppuccin: persist theme on reboot

This commit is contained in:
LavaDesu 2025-03-19 13:52:11 +11:00
parent 3c5d4ba108
commit f9de112a18
Signed by: cilly
GPG key ID: 6500251E087653C9

View file

@ -34,8 +34,19 @@
};
home.packages = [(pkgs.writeShellScriptBin "theme" ''
if [ "$1" != "dark" ] && [ "$1" != "light" ]; then
echo "invalid theme, valid values: [dark, light]"
last_path="$HOME/.local/state/last-theme"
target="$1"
if [ "$target" == "restore" ]; then
echo "restoring theme"
if [ ! -e "$last_path" ]; then
echo "no last theme found; assuming dark"
target="dark"
else
target=$(cat "$last_path" | tr -d "\n")
fi
fi
if [ "$target" != "dark" ] && [ "$target" != "light" ]; then
echo "invalid theme, valid values: [dark, light, restore]"
exit 1
fi
current="$HOME/.local/state/nix/profiles/home-manager"
@ -52,7 +63,9 @@
exit 1
fi
"$cached/specialisation/$1/activate"
"$cached/specialisation/$target/activate"
echo "$target" > "$last_path"
'')];
};
}