30 lines
796 B
Nix
30 lines
796 B
Nix
{ 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;
|
|
};
|
|
}
|