all repos — nixfiles @ 3a3ae397ce411c1d00d30ad06c85032082318811

System and user configuration, managed by nix and home-manager

move kitty dark/light toggle to kitty.nix

Alan Pearce
commit

3a3ae397ce411c1d00d30ad06c85032082318811

parent

b7e7257733a091db14d0c01adc95eee974344c1e

2 files changed, 34 insertions(+), 12 deletions(-)

jump to
M user/settings/darwin.nixuser/settings/darwin.nix
@@ -66,6 +66,7 @@ toString
( pkgs.writeShellScript "toggle-dark-light-mode" + ( '' wait4path /nix if defaults read -g AppleInterfaceStyle &>/dev/null ; then
@@ -74,7 +75,6 @@ else
MODE="light" fi emacsclient="${config.programs.emacs.finalPackage}/bin/emacsclient" - kitty="${pkgs.kitty}/bin/kitty +kitten themes --config-file-name=theme.conf --reload-in=all --cache-age=-1" emacsSwitchTheme () { if pgrep -q Emacs; then if [[ $MODE == "dark" ]]; then
@@ -88,18 +88,9 @@ --eval "(modify-all-frames-parameters '((ns-appearance '$MODE)))"
fi fi } - kittySwitchTheme () { - if pgrep -q kitty; then - if [[ $MODE == "dark" ]]; then - $kitty 'Modus Vivendi' - elif [[ $MODE == "light" ]]; then - $kitty 'Modus Operandi' - fi - fi - } emacsSwitchTheme - kittySwitchTheme '' + ) ) ) ];
M user/settings/kitty.nixuser/settings/kitty.nix
@@ -1,4 +1,5 @@
-{ pkgs +{ config +, pkgs , ... }: {
@@ -23,5 +24,35 @@ };
extraConfig = '' include ~/.config/kitty/theme.conf ''; + }; + launchd.agents.kitty-dark-light = { + enable = true; + config = { + WatchPaths = [ "${config.home.homeDirectory}/Library/Preferences/.GlobalPreferences.plist" ]; + StandardOutputPath = "/dev/null"; + StandardErrorPath = "/dev/null"; + RunAtLoad = true; + KeepAlive = false; + ProgramArguments = [ + "/bin/sh" + (toString (pkgs.writeShellScript "toggle-dark-light-mode" '' + wait4path /nix + if defaults read -g AppleInterfaceStyle &>/dev/null ; then + MODE="dark" + else + MODE="light" + fi + kitty="${pkgs.kitty}/bin/kitty +kitten themes --config-file-name=theme.conf --reload-in=all --cache-age=-1" + if pgrep -q kitty; then + if [[ $MODE == "dark" ]]; then + $kitty 'Modus Vivendi' + elif [[ $MODE == "light" ]]; then + $kitty 'Modus Operandi' + fi + fi + '' + )) + ]; + }; }; }