Use specialisation to switch themes on NixOS
This commit is contained in:
parent
b94e030619
commit
6b00a19d0c
3 changed files with 18 additions and 4 deletions
|
@ -3,7 +3,8 @@ let
|
|||
# Currently last commit in https://github.com/danth/stylix/pull/194
|
||||
stylix = builtins.fetchTarball "https://github.com/willemml/stylix/archive/2ed2b0086b41d582aca26e083c19c0e47c8991e3.tar.gz";
|
||||
polarityFile = "${config.xdg.stateHome}/theme_polarity";
|
||||
polarity = if builtins.pathExists polarityFile then lib.strings.fileContents polarityFile else "light";
|
||||
polarityFromFile = if builtins.pathExists polarityFile then lib.strings.fileContents polarityFile else "light";
|
||||
polarity = if config.frogeye.polarity == "dynamic" then polarityFromFile else config.frogeye.polarity;
|
||||
phases = [
|
||||
{ command = "jour"; polarity = "light"; }
|
||||
{ command = "crepuscule"; polarity = "dark"; }
|
||||
|
@ -53,13 +54,15 @@ in
|
|||
runtimeInputs = [ pkgs.brightnessctl ];
|
||||
text = (lib.optionalString cfg.enable ''
|
||||
brightnessctl set ${builtins.getAttr phase.command cfg}
|
||||
'') + ''
|
||||
'') + ''
|
||||
echo ${phase.polarity} > ${polarityFile}
|
||||
if command -v home-manager
|
||||
then
|
||||
home-manager switch
|
||||
else
|
||||
sudo nixos-rebuild switch
|
||||
# In two steps to get the visual changes slightly earlier
|
||||
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration test
|
||||
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration boot
|
||||
fi
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue