about summary refs log tree commit diff
path: root/home/profiles/gui/config/sway.nix
blob: 36b1b955c09c4c59b35409feccbe9b0f99c20ba6 (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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
{ config, pkgs, neotheme }:

with neotheme.colors;

let
  guiCfg = config.profiles.gui;
in
''
  # disable power key
  exec systemd-inhibit --what=handle-power-key --who="sway" --why="Sway manages power key behaviour" sleep infinity

  exec autotiling

  # HACK: https://todo.sr.ht/~emersion/kanshi/35
  exec_always "systemctl --user restart kanshi.service"

  # Link keychain: https://github.com/systemd/systemd/issues/5522#issuecomment-309226589
  exec [ -x "$(command -v keyctl)" ] && keyctl link @u @s

  exec systemctl start --user fcitx5-daemon

  # set modifiers
  set $mod Mod4
  set $alt Mod1
  set $floating_modifier $mod
  set $left  h
  set $down  j
  set $up    k
  set $right l

  # set terminal

  set $term foot
  bindsym $mod+Return exec $term

  # set menu
    set $menu "${pkgs.bemenu}/bin/bemenu-run -H 18 -l 5 --fn '${guiCfg.font.name} ${toString guiCfg.font.pixelSize}px' -p 'run::' --tb '$primary' --tf '$color0' --hb '$primary' --hf '$color0'"
  bindsym $mod+d exec $menu

  # change focus
  # vim-style
  bindsym $mod+$left  focus left
  bindsym $mod+$down  focus down
  bindsym $mod+$up    focus up
  bindsym $mod+$right focus right
  # arrows
  bindsym $mod+Left  focus left
  bindsym $mod+Down  focus down
  bindsym $mod+Up    focus up
  bindsym $mod+Right focus right

  # move focused window
  # vim-style
  bindsym $mod+Shift+$left move left
  bindsym $mod+Shift+$down move down
  bindsym $mod+Shift+$up move up
  bindsym $mod+Shift+$right move right
  # arrows
  bindsym $mod+Shift+Left move left
  bindsym $mod+Shift+Down move down
  bindsym $mod+Shift+Up move up
  bindsym $mod+Shift+Right move right

  # split
  bindsym $mod+c split h # horizontal
  bindsym $mod+v split v # vertical

  # fullscreen
  bindsym $mod+e fullscreen toggle

  # floating
  bindsym $mod+f floating toggle

  # kill focused
  bindsym $mod+w kill

  font "pango:${guiCfg.font.name} ${toString guiCfg.font.size}"

  # window rules
  for_window [window_role="pop-up"]      floating enable
  for_window [window_role="bubble"]      floating enable
  for_window [window_role="task_dialog"] floating enable
  for_window [window_role="Preferences"] floating enable
  for_window [window_type="dialog"]      floating enable
  for_window [window_type="menu"]        floating enable
  for_window [class="mpv"]               floating enable
  for_window [class=".*"]                inhibit_idle fullscreen
  for_window [app_id=".*"]               title_format ""
  for_window [class=".*"]                title_format ""

  titlebar_border_thickness 0
  titlebar_padding 0 0

  # workspace names
  set $ws1 1:I
  set $ws2 2:II
  set $ws3 3:III
  set $ws4 4:IV
  set $ws5 5:V
  set $ws6 6:VI
  set $ws7 7:VII
  set $ws8 8:VIII
  set $ws9 9:IX
  set $ws10 10:X

  # switch to named ws
  bindsym $mod+1 workspace $ws1
  bindsym $mod+2 workspace $ws2
  bindsym $mod+3 workspace $ws3
  bindsym $mod+4 workspace $ws4
  bindsym $mod+5 workspace $ws5
  bindsym $mod+6 workspace $ws6
  bindsym $mod+7 workspace $ws7
  bindsym $mod+8 workspace $ws8
  bindsym $mod+9 workspace $ws9
  bindsym $mod+0 workspace $ws10

  # switch to prev/next ws
  bindsym $mod+z workspace prev
  bindsym $mod+x workspace next

  # move focused container to ws
  bindsym $mod+Shift+1 move container to workspace $ws1
  bindsym $mod+Shift+2 move container to workspace $ws2
  bindsym $mod+Shift+3 move container to workspace $ws3
  bindsym $mod+Shift+4 move container to workspace $ws4
  bindsym $mod+Shift+5 move container to workspace $ws5
  bindsym $mod+Shift+6 move container to workspace $ws6
  bindsym $mod+Shift+7 move container to workspace $ws7
  bindsym $mod+Shift+8 move container to workspace $ws8
  bindsym $mod+Shift+9 move container to workspace $ws9
  bindsym $mod+Shift+0 move container to workspace $ws10
  bindsym $mod+Shift+z move container to workspace prev
  bindsym $mod+Shift+x move container to workspace next

  # move container to different display
  bindsym $mod+$alt+Left move container to output left
  bindsym $mod+$alt+Right move container to output right
  bindsym $mod+$alt+Up move container to output up
  bindsym $mod+$alt+Down move container to output down

  # move ws to different display
  bindsym $mod+Ctrl+Left move workspace to output left
  bindsym $mod+Ctrl+Right move workspace to output right
  bindsym $mod+Ctrl+Up move workspace to output up
  bindsym $mod+Ctrl+Down move workspace to output down

  # ws back-and-forth
  workspace_auto_back_and_forth no

  # reload
  bindsym $mod+r reload

  # application shortcuts
  bindsym $mod+a exec qutebrowser
  # bindsym $mod+Shift+a

  # Volume control
  bindsym XF86AudioRaiseVolume exec amixer set Master 5%+
  bindsym XF86AudioLowerVolume exec amixer set Master 5%-
  bindsym XF86AudioMute        exec amixer set Master toggle
  bindsym XF86AudioMicMute     exec amixer set Capture toggle
  # HHKB
  bindsym $mod+equal           exec amixer set Master 5%+
  bindsym $mod+minus           exec amixer set Master 5%-
  bindsym $mod+backslash       exec amixer set Master toggle

  # Brightness
  bindsym XF86MonBrightnessDown exec brightnessctl -q set 10%-
  bindsym XF86MonBrightnessUp   exec brightnessctl -q set 10%+

  # Aeroplane mode
  bindsym XF86WLAN exec ${pkgs.writeShellScript "aeroplane-mode" (import ../scripts/aeroplane-mode.nix)}

  # Display mirroring
  bindsym XF86Display exec wl-present mirror

  # Screenshot
  bindsym $mod+Ctrl+Return exec grimshot copy area
  bindsym $mod+Print exec grimshot copy area
  bindsym Print      exec grimshot copy active
  bindsym $alt+Print exec grimshot save screen

  # Colour picker
  bindsym $mod+Shift+Return exec wl-color-picker

  # Toggle waybar
  bindsym $mod+b exec pkill -USR1 waybar

  # Session control
  bindsym $mod+q exec loginctl lock-session
  bindsym $mod+Shift+q exec swaynag -t warning -m 'Do you really want to exit sway?' -b 'Yes, exit sway' 'swaymsg exit'
  bindsym --locked $mod+Shift+q exec loginctl terminate-session self
  bindsym --locked $mod+Ctrl+q exec systemctl suspend

  # Power
  bindsym XF86PowerOff exec swaynag -t error -m 'Confirm poweroff?' -b 'Confirm' 'shutdown now'

  # Aesthetics
  default_border pixel 3
  hide_edge_borders --i3 smart
  gaps inner 8
  smart_borders on

  set $color0 #${color0}
  set $color1 #${color1}
  set $color2 #${color2}
  set $color3 #${color3}
  set $color4 #${color4}
  set $color5 #${color5}
  set $color6 #${color6}
  set $color7 #${color7}
  set $color8 #${bright0}
  set $color9 #${bright1}
  set $color10 #${bright2}
  set $color11 #${bright3}
  set $color12 #${bright4}
  set $color13 #${bright5}
  set $color14 #${bright6}
  set $color15 #${bright7}

  set $primary $color4
  set $muted #36486a

  # class                 border    backgr    text    indicator
  client.focused          $primary $primary $color0 $primary
  client.focused_inactive $muted $muted $color0 $muted
  client.unfocused        $muted $muted $color7 $muted
  client.urgent           $color10 $color10 $color0 $color10
  output "*" bg ${../../../../assets/annie-spratt-arctic.jpg} fill
  output eDP-1 scale 1.25
  # output "*" scale 1
  # output "*" scale_filter smart

  input type:touchpad {
    tap enabled
    natural_scroll enabled
  }


  input "1452:641:Apple_Internal_Keyboard_/_Trackpad" {
    dwt enabled                 #Disable while typing
    tap enabled                 #Tap registers as a click
    accel_profile adaptive      #adaptive/flat cursor acceleration
    pointer_accel 0             #From -1 to 1: Speed of cursor
    natural_scroll enabled      #Direction of Scroll
    scroll_factor 0.3           #Speed of Scrolling gets multiplied by this factor
    scroll_method two_finger    #none|two_finger|edge|on_button_down
    middle_emulation enabled    #Enables middle click
    tap_button_map lmr          #1Finger > Left Click , 2Finger > Right Click, 3Fingers > MiddleClick
  }

  input "1149:8264:Primax_Kensington_Eagle_Trackball" {
    accel_profile flat
    pointer_accel 0
  }

  input type:keyboard {
    repeat_rate 40
    repeat_delay 350
    xkb_layout us
    # xkb_variant ,dvorak
    # xkb_options 'grp:alt_shift_toggle,caps:escape'
    # xkb_options ctrl:swapcaps
  }
''