all repos — nixfiles @ main

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

user/settings/kitty.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
  config,
  pkgs,
  ...
}:
{
  programs.kitty = {
    enable = true;
    font = {
      package = pkgs.recursive;
      name = "Rec Mono SemiCasual";
      size = 15;
    };
    shellIntegration = {
      mode = "no-cursor";
    };
    keybindings = {
      "ctrl+shift+t" = "new_tab_with_cwd !neighbor";
      "cmd+t" = "new_tab_with_cwd !neighbor";
    };
    settings = {
      macos_option_as_alt = "left";
      cursor_blink_interval = 0;
    };
    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
          ''
        ))
      ];
    };
  };
}