~sumner/home-manager-config

ref: 4773c5957ca802109624acb2aa3389cac95dd304 home-manager-config/modules/window-manager/common.nix -rw-r--r-- 6.5 KiB
4773c595Sumner Evans add hm dirhash 8 months ago
                                                                                
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
{ config, lib, pkgs }: with lib; {
  redshiftGammastepCfg = {
    enable = true;
    provider = "geoclue2";
    tray = true;

    temperature = {
      day = 5500;
      night = 4000;
    };
  };

  notificationColorConfig = {
    urgency_low = {
      frame_color = "#777777";
      foreground = "#777777";
      background = "#191311";
      timeout = 4;
    };

    urgency_normal = {
      frame_color = "#5B8234";
      foreground = "#5B8234";
      background = "#191311";
      timeout = 8;
    };

    urgency_critical = {
      frame_color = "#B7472A";
      foreground = "#B7472A";
      background = "#191311";
      timeout = 12;
    };
  };

  i3SwayConfig = let
    resizeStr = "  ";
    gapSize = 6;
    workspaces = [ "1: " "2" "3" "4" "5" "6" "7" "8" "9" "10" ];
    extraWorkspaces = [
      { name = "11: "; keycode = 20; }
      { name = "12: "; keycode = 21; }
    ];

    left = "h";
    down = "j";
    up = "k";
    right = "l";
    fonts = [ "Iosevka" "FontAwesome 10" ];

    menucalc = pkgs.callPackage ../../pkgs/menucalc.nix {};
  in
    {
      enable = true;
      config = rec {
        inherit fonts;
        gaps.inner = gapSize;
        modifier = config.windowManager.modKey;
        terminal = config.home.sessionVariables.TERMINAL;

        assigns = {
          # Browsers
          "${elemAt workspaces 0}" = [
            { class = "Firefox"; }
          ];

          # Chat Clients
          "${(elemAt extraWorkspaces 0).name}" = [
            { class = "discord"; }
            { class = "Element"; }
            { class = "Slack"; }
            { class = "Telegram"; }
            { title = "Mutt"; }
          ];

          # Music
          "${(elemAt extraWorkspaces 1).name}" = [
            { class = "sublime-music"; }
          ];
        };

        bars = [
          {
            inherit fonts;
            position = "top";
            statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${config.xdg.configHome}/i3status-rust/config-top.toml";
            colors = {
              background = "#00000090";
              separator = "#aaaaaa";
            };
          }
        ];

        floating.criteria = [
          { instance = "pinentry"; }
          { title = "Firefox - Sharing Indicator"; }
        ];

        keybindings = listToAttrs (
          # Switch to workspace
          (imap1 (i: name: { name = "${modifier}+${toString (mod i 10)}"; value = ''workspace "${name}"''; }) workspaces)
          # Move to workspace
          ++ (imap1 (i: name: { name = "${modifier}+Shift+${toString (mod i 10)}"; value = ''move container to workspace "${name}"''; }) workspaces)
        ) // {
          "${modifier}+Return" = "exec ${terminal}";
          "${modifier}+Shift+q" = "kill";

          # RESTART SWAY IN-PLACE (PRESERVES YOUR LAYOUT/SESSION, CAN BE USED TO UPGRADE SWAY)
          "${modifier}+Shift+R" = "reload";

          # LAUNCHERS
          "${modifier}+d" = "exec ${pkgs.rofi}/bin/rofi -show run";
          "${modifier}+space" = "exec ${pkgs.rofi}/bin/rofi -show drun -show-icons";
          F4 = "exec ${menucalc}/bin/= -- -lines 3"; # menu-calc
          F3 = "exec ${pkgs.rofi-pass}/bin/rofi-pass -- -i";

          # FOCUS
          "${modifier}+${left}" = "focus left";
          "${modifier}+${down}" = "focus down";
          "${modifier}+${up}" = "focus up";
          "${modifier}+${right}" = "focus right";

          # MOVEMENT
          "${modifier}+Shift+${left}" = "move left";
          "${modifier}+Shift+${down}" = "move down";
          "${modifier}+Shift+${up}" = "move up";
          "${modifier}+Shift+${right}" = "move right";

          # SPLIT IN HORIZONTAL/VERTICAL ORIENTATION
          "${modifier}+semicolon" = "split h";
          "${modifier}+v" = "split v";

          # CHANGE CONTAINER LAYOUT (STACKED, TABBED, TOGGLE SPLIT)
          "${modifier}+s" = "layout stacking";
          "${modifier}+w" = "layout tabbed";
          "${modifier}+e" = "layout toggle split";

          # ENTER FULLSCREEN MODE FOR THE FOCUSED CONTAINER
          "${modifier}+f" = "fullscreen toggle";

          # TOGGLE TILING / FLOATING
          button2 = "floating toggle";
          "${modifier}+Shift+space" = "floating toggle";

          # FOCUS THE PARENT CONTAINER
          "${modifier}+a" = "focus parent";

          # RESIZE
          "${modifier}+r" = ''mode "${resizeStr}"'';

          # GAPS
          "${modifier}+F3" = "gaps inner all set 0";
          "${modifier}+Shift+F3" = "gaps inner all set ${toString gapSize}";

          # VOLUME KEYS
          XF86AudioLowerVolume = "exec amixer set Master playback 2%-";
          XF86AudioRaiseVolume = "exec amixer set Master playback 2%+";
          XF86AudioMute = "exec amixer set Master toggle";

          # MEDIA CONTROLS
          XF86AudioPrev = "exec playerctl previous";
          XF86AudioPlay = "exec playerctl play-pause";
          XF86AudioStop = "exec playerctl stop";
          XF86AudioNext = "exec playerctl next";

          # SCREEN BRIGHTNESS CONTROLS
          XF86MonBrightnessDown = mkIf config.laptop.enable "exec brightnessctl s 5%-";
          XF86MonBrightnessUp = mkIf config.laptop.enable "exec brightnessctl s +5%";
        };

        keycodebindings = listToAttrs (
          # Switch to workspace
          (imap1 (i: { name, keycode }: { name = "${modifier}+${toString keycode}"; value = ''workspace "${name}"''; }) extraWorkspaces)
          # Move to workspace
          ++ (imap1 (i: { name, keycode }: { name = "${modifier}+Shift+${toString keycode}"; value = ''move container to workspace "${name}"''; }) extraWorkspaces)
        ) // {
          "${modifier}+34" = "exec ${config.home.homeDirectory}/bin/mutt_helper"; # Launch mutt
          "${modifier}+35" = "exec ${pkgs.element-desktop}/bin/element-desktop"; # Launch Element
        };

        modes = {
          "${resizeStr}" = {
            "${left}" = "resize shrink width 10 px or 10 ppt";
            "${down}" = "resize grow height 10 px or 10 ppt";
            "${up}" = "resize shrink height 10 px or 10 ppt";
            "${right}" = "resize grow width 10 px or 10 ppt";
            "Left" = "resize shrink width 10 px or 10 ppt";
            "Down" = "resize grow height 10 px or 10 ppt";
            "Up" = "resize shrink height 10 px or 10 ppt";
            "Right" = "resize grow width 10 px or 10 ppt";
            "Escape" = "mode default";
            "Return" = "mode default";
            "${modifier}+r" = "mode default";
          };
        };

        window = {
          border = 0;
          hideEdgeBorders = "both";
        };
      };
    };
}