diff options
author | Alan Pearce | 2024-12-29 19:59:10 +0100 |
---|---|---|
committer | Alan Pearce | 2024-12-29 19:59:10 +0100 |
commit | 3a3ae397ce411c1d00d30ad06c85032082318811 (patch) | |
tree | 5fca81e769c842d96f072307651edd4d85caa97f /user/settings | |
parent | b7e7257733a091db14d0c01adc95eee974344c1e (diff) | |
download | nixfiles-3a3ae397ce411c1d00d30ad06c85032082318811.tar.lz nixfiles-3a3ae397ce411c1d00d30ad06c85032082318811.tar.zst nixfiles-3a3ae397ce411c1d00d30ad06c85032082318811.zip |
move kitty dark/light toggle to kitty.nix
Diffstat (limited to 'user/settings')
-rw-r--r-- | user/settings/darwin.nix | 13 | ||||
-rw-r--r-- | user/settings/kitty.nix | 33 |
2 files changed, 34 insertions, 12 deletions
diff --git a/user/settings/darwin.nix b/user/settings/darwin.nix index 1ea3d470..1c0f6a74 100644 --- a/user/settings/darwin.nix +++ b/user/settings/darwin.nix @@ -66,6 +66,7 @@ ( pkgs.writeShellScript "toggle-dark-light-mode" + ( '' wait4path /nix if defaults read -g AppleInterfaceStyle &>/dev/null ; then @@ -74,7 +75,6 @@ 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 @@ 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 '' + ) ) ) ]; diff --git a/user/settings/kitty.nix b/user/settings/kitty.nix index 8a06a820..c80c5fbd 100644 --- a/user/settings/kitty.nix +++ b/user/settings/kitty.nix @@ -1,4 +1,5 @@ -{ pkgs +{ config +, pkgs , ... }: { @@ -24,4 +25,34 @@ 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 + '' + )) + ]; + }; + }; } |