aboutsummaryrefslogtreecommitdiff
path: root/modules/terminal/hjem/programs/tmux.nix
blob: d6c7cf8c875a2c0a1723fd2fe8406c23720c390f (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
  pkgs,
  inputs,
  lib,
  config,
  ...
}: let
  cfg = config.collinux.terminal.programs.tmux;
in {
  imports = [
    inputs.tmux-tsunami.hjemModules.tsunami
  ];

  config = lib.mkIf cfg.enable {
    tsunami = {
      enable = true;

      theme =
        if (cfg.theme == "catppuccin")
        then {
          bg = "#1e1e2e";
          bg_dark = "#181825";
        }
        else if (cfg.theme == "adwaita")
        then {
          bg = "#1d1d1d";
          bg_dark = "#171717";
        }
        else {};

      scripts.switch_to_utility =
        # bash
        ''
          # if utility session doesn't exist, create it
          if ! tmux has-session -t "utility"; then
            tmux new-session -ds "utility" -c "$HOME"
          fi

          if [ -z "$TMUX" ]; then
            # we're not in tmux
            tmux attach-session -t "utility"
          else
            tmux switch -t "utility"
          fi

          # if cmus window doesn't exist, create it
          if ! tmux list-windows -t "utility" -F "#{window_name}" | grep -qx "utility_cmus"; then
            tmux new-window -t "utility" -n "utility_cmus" "cmus"
          fi

          # if bluetuith window doesn't exist, create it
          if ! tmux list-windows -t "utility" -F "#{window_name}" | grep -qx "utility_bluetuith"; then
            tmux new-window -t "utility" -n "utility_bluetuith" "bluetuith"
          fi
        '';

      keys.leader = [
        {
          name = "Lazygit";
          key = "C-g";
          exec = "display-popup -E -w 80% -h 80% -x C -y C -d '#{?@default-path,#{@default-path},#{pane_current_path}}' ${lib.getExe pkgs.lazygit}";
        }
        {
          name = "Utility";
          key = "C-u";
          exec = "display-popup -w 80% -h 80% -x C -y C 'TMUX= ~/.config/tmux/scripts/switch_to_utility.sh'";
        }
      ];
      confs."main" = ''
        set -g mouse on
        set-window-option -g mode-keys vi
      '';
    };
  };
}