add: theme-switcher

This commit is contained in:
2025-02-16 14:41:48 +09:00
parent d40fbe7eed
commit a4ff711bc3
8 changed files with 124 additions and 11 deletions
+11
View File
@@ -0,0 +1,11 @@
{
imports = [
./theme-switcher.nix
];
home.activation = {
makedir = ''
mkdir -p ~/.config/cornflake
'';
};
}
+29
View File
@@ -0,0 +1,29 @@
{ pkgs, ... }:
let
apply-theme-script = pkgs.writeScript "apply-theme" ''
curr=$(cat ~/.config/cornflake/current-theme)
if [ "$curr" = "prefer-light" ]; then
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-light'"
else
dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
fi
'';
desktopEntry = {
name = "Toggle theme";
exec = ''${pkgs.writeScript "theme" ''
curr=$(cat ~/.config/cornflake/current-theme)
if [ "$curr" = "prefer-light" ]; then
echo 'prefer-dark' > ~/.config/cornflake/current-theme
else
echo 'prefer-light' > ~/.config/cornflake/current-theme
fi
${apply-theme-script}
''}'';
};
in
{
xdg.desktopEntries = {
theme-switcher = desktopEntry;
};
}