aboutsummaryrefslogtreecommitdiff
path: root/modules/workstation/graphics/i3/config.nix
blob: 746c2a47698187893d427f55cc52be3294f6b905 (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
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
{ pkgs, wallpaper }:

{
  enable = true;
  package = pkgs.i3;
  config = rec {
    modifier = "Mod4";

    # Use iosevka as default font
    fonts = [ "iosevka-term-ss09 10" ];

    keybindings = {

      # Start a terminal
      "${modifier}+Return" = "exec kitty";

      # Close individual windows
      "${modifier}+Shift+q" = "kill";

      # Full-screen window
      "${modifier}+f" = "fullscreen";

      # Start software on <this> or <other> workspace
      "${modifier}+d" = "exec dmenu_run";
      "${modifier}+Shift+d" = "exec ~/.config/i3/dynamic-tags/move.sh";

      # Move focus around - vim style
      "${modifier}+h" = "focus left";
      "${modifier}+j" = "focus down";
      "${modifier}+k" = "focus up";
      "${modifier}+l" = "focus right";

      # Move focus around - boring style
      "${modifier}+Up" = "focus up";
      "${modifier}+Down" = "focus down";
      "${modifier}+Left" = "focus left";
      "${modifier}+Right" = "focus right";

      # Move windows - vim style
      "${modifier}+Shift+k" = "move up";
      "${modifier}+Shift+j" = "move down";
      "${modifier}+Shift+h" = "move left";
      "${modifier}+Shift+l" = "move right";

      # Move windows - boring style
      "${modifier}+Shift+Up" = "move up";
      "${modifier}+Shift+Down" = "move down";
      "${modifier}+Shift+Left" = "move left";
      "${modifier}+Shift+Right" = "move right";

      # Move workspaces between multi-monitor setups
      "${modifier}+Ctrl+Shift+Up" = "move workspace to output up";
      "${modifier}+Ctrl+Shift+Down" = "move workspace to output down";
      "${modifier}+Ctrl+Shift+Left" = " move workspace to output left";
      "${modifier}+Ctrl+Shift+Right" = "move workspace to output right";

      # Define split behaviours
      "${modifier}+2" = "split h";
      "${modifier}+1" = "split v";

      # A very fortunate lockscreen
      "${modifier}+Ctrl+l" = "exec --no-startup-id i3lock -c 333333";
      "${modifier}+Ctrl+Shift+l" = "exec --no-startup-id systemctl hibernate";

      # Rename workspaces
      "${modifier}+Ctrl+r" = "exec i3-input -F 'rename workspace to \"%s\"' -P 'New name: '";

      # Switch to workspace (optionally dragging windows with)
      "${modifier}+s" = "exec ~/.config/i3/dynamic-tags/switch.sh -fn '$dfont'";
      "${modifier}+Shift+s" = "exec ~/.config/i3/dynamic-tags/move.sh -fn '$dfont'";

      # Some layout modifiers
      "${modifier}+e" = "layout default";
      "${modifier}+w" = "layout tabbed";
      "${modifier}+q" = "layout stacked";

      # Do I even use this?!
      "${modifier}+Shift+space" = "floating toggle";
      "${modifier}+space" = "focus mode_toggle";

      # Focus the parent containers
      "${modifier}+a" = "focus parent";

      # Audio is good actually
      "XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%";
      "XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%";
      "XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle";

      # Reload, restart and quit i3
      "${modifier}+Shift+c" = "reload";
      "${modifier}+Shift+r" = "restart";
      "${modifier}+Shift+e" = ''
        exec i3-nagbar -t warning -m "Workspaces are sentient, you know. \
        We just have a lot of them" "i3-msg exit"
      '';

      # Switch to resize mode (defined below)
      "${modifier}+r" = "mode \"resize\"";

      # FIXME: What was this again?!
      "button4" = "nop";
      "button5" = "nop";
    };

    modes = {

      # Explicitly handle the resize mode
      resize = {
        "h" = "resize shrink width 5 px or 5 ppt";
        "j" = "resize grow height 5 px or 5 ppt";
        "k" = "resize shrink height 5 px or 5 ppt";
        "l" = "resize grow width 5 px or 5 ppt";

        # same bindings, but for the arrow keys
        "Left" = "resize shrink width 5 px or 5 ppt";
        "Down" = "resize grow height 5 px or 5 ppt";
        "Up" = "resize shrink height 5 px or 5 ppt";
        "Right" = "resize grow width 5 px or 5 ppt";

        # back to normal: Enter or Escape or $mod+r
        "Return" = "mode \"default\"";
        "Escape" = "mode \"default\"";
        "${modifier}+r" = "mode \"default\"";
      } ;
    };

    # The `bars` module does weird stuff so we init it ourselves
    bars = [];
  };

  extraConfig = with pkgs; ''
    # Compton
    exec_always --no-startup-id "pkill compton; ${compton}/bin/compton \
                --config ~/.config/i3/compton.conf"

    # Make CAPSLOCK into ESC because it's 2018
    #
    # Okay actually this is slightly more complicated than that. Actually I'm
    # binding CAPSLOCK to HYPER, so that I can use it as a modifier in emacs,
    # but then using xcape(1) to also make short CAPSLOCK presses into ESCAPE.

    exec_always --no-startup-id "${xorg.xmodmap}/bin/setxkbmap \
                -layout us -variant altgr-intl -option caps:hyper"
    exec ${xcape}/bin/xcape -e "#66=Escape" -t 150

    # Always set a wallpaper
    exec_always --no-startup-id ${feh}/bin/feh --bg-fill ${wallpaper}

    bar {
        status_command i3status -c ~/.config/i3/i3status.conf
        position bottom
        bindsym button4 nop
        bindsym button5 nop
        colors  {
            background #0F0F0F
            statusline #D5D5D5
        }k
    }

    focus_follows_mouse no

    # Layout and design settings that should _really_ be in the module
    default_border pixel 3
    client.focused #4c7899 #285577 #ffffff #F73E5F #666666
  '';
}