From 8818d8a1aab5d3035f643f0e47d2bd242db505e3 Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Tue, 18 Mar 2025 18:01:59 +1100 Subject: [PATCH] user/catppuccin: create specialisation switcher --- modules/user/catppuccin.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/user/catppuccin.nix b/modules/user/catppuccin.nix index cf22df4..f16d161 100644 --- a/modules/user/catppuccin.nix +++ b/modules/user/catppuccin.nix @@ -1,4 +1,4 @@ -{ config, inputs, lib, ... }: { +{ config, inputs, lib, pkgs, ... }: { imports = [ inputs.catppuccin.homeManagerModules.catppuccin ]; @@ -32,5 +32,27 @@ light.configuration.catppuccin.flavor = "latte"; dark.configuration.catppuccin.flavor = "mocha"; }; + + home.packages = [(pkgs.writeShellScriptBin "theme" '' + if [ "$1" != "dark" ] && [ "$1" != "light" ]; then + echo "invalid theme, valid values: [dark, light]" + exit 1 + fi + current="$HOME/.local/state/nix/profiles/home-manager" + cached="$HOME/.local/state/last-parent-specialisation" + if [ -d "$current/specialisation" ]; then + if [ -d "$cached" ]; then + rm -f "$cached" + fi + ln -sf "$(readlink -f $current)" "$cached" + fi + + if [ ! -d "$cached/specialisation" ]; then + echo "no specialisations found" + exit 1 + fi + + "$cached/specialisation/$1/activate" + '')]; }; }