diff options
Diffstat (limited to 'accounts/gkleen@sif/niri/default.nix')
-rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 461 |
1 files changed, 401 insertions, 60 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 6aa4391c..bfc32254 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix | |||
@@ -2,30 +2,32 @@ | |||
2 | let | 2 | let |
3 | niri = config.programs.niri.package; | 3 | niri = config.programs.niri.package; |
4 | terminal = lib.getExe config.programs.kitty.package; | 4 | terminal = lib.getExe config.programs.kitty.package; |
5 | lightctl = lib.getExe' config.services.avizo.package "lightctl"; | 5 | makoctl = lib.getExe' config.services.mako.package "makoctl"; |
6 | volumectl = lib.getExe' config.services.avizo.package "volumectl"; | ||
7 | dunstctl = lib.getExe' config.services.dunst.package "dunstctl"; | ||
8 | loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; | 6 | loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; |
9 | systemctl = lib.getExe' hostConfig.systemd.package "systemctl"; | 7 | systemctl = lib.getExe' hostConfig.systemd.package "systemctl"; |
8 | swayosd-client = lib.getExe' config.services.swayosd.package "swayosd-client"; | ||
10 | 9 | ||
11 | focus-or-spawn = pkgs.writeShellApplication { | 10 | focus_or_spawn = pkgs.writeShellApplication { |
12 | name = "focus-or-spawn"; | 11 | name = "focus-or-spawn"; |
13 | runtimeInputs = [ niri pkgs.gojq pkgs.gnugrep pkgs.socat ]; | 12 | runtimeInputs = [ niri pkgs.gojq pkgs.gnugrep pkgs.socat ]; |
14 | text = '' | 13 | text = '' |
15 | app_id="$1" | 14 | window_select="$1" |
16 | shift | 15 | shift |
17 | workspace_name="$1" | 16 | workspace_name="$1" |
18 | shift | 17 | shift |
19 | 18 | ||
20 | workspaces_json="$(niri msg -j workspaces)" | 19 | workspaces_json="$(niri msg -j workspaces)" |
21 | workspace_output="$(jq -r --arg workspace_name "$workspace_name" '.[] | select(.name == $workspace_name) | .output' <<<"$workspaces_json")" | 20 | workspace_output="$(jq -r --arg workspace_name "$workspace_name" '.[] | select(.name == $workspace_name) | .output' <<<"$workspaces_json")" |
22 | active_workspace="$(jq -r --arg workspace_output "$workspace_output" '.[] | select(.output == $workspace_output and .is_active) | .id' <<<"$workspaces_json")" | 21 | # active_workspace="$(jq -r --arg workspace_output "$workspace_output" '.[] | select(.output == $workspace_output and .is_active) | .id' <<<"$workspaces_json")" |
23 | niri msg action move-workspace-to-monitor --output "$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" "$workspace_name" | 22 | active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" |
24 | socat STDIO "$NIRI_SOCKET" <<<'{"Action":{"FocusWorkspace":{"reference":{"Id":'"''${active_workspace}"'}}}}' | 23 | if [[ $workspace_output != "$active_output" ]]; then |
25 | niri msg action move-workspace-to-index --index 1 "$workspace_name" | 24 | niri msg action move-workspace-to-monitor --reference "$workspace_name" "$active_output" |
25 | # socat STDIO "$NIRI_SOCKET" <<<'{"Action":{"FocusWorkspace":{"reference":{"Id":'"''${active_workspace}"'}}}}' | ||
26 | # niri msg action move-workspace-to-index --reference "$workspace_name" 1 | ||
27 | fi | ||
26 | 28 | ||
27 | while IFS=$'\n' read -r window_json; do | 29 | while IFS=$'\n' read -r window_json; do |
28 | if jq -r '.app_id' <<<"$window_json" | grep -q "$app_id"; then | 30 | if [[ -n $(jq -c "$window_select" <<<"$window_json") ]]; then |
29 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" | 31 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" |
30 | exit 0 | 32 | exit 0 |
31 | fi | 33 | fi |
@@ -34,10 +36,92 @@ let | |||
34 | exec "$@" | 36 | exec "$@" |
35 | ''; | 37 | ''; |
36 | }; | 38 | }; |
37 | focus-or-spawn-action = app_id: workspace_name: config.lib.niri.actions.spawn (lib.getExe focus-or-spawn) (lib.escapeShellArg app_id) (lib.escapeShellArg workspace_name); | 39 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); |
40 | focus-or-spawn-action-app_id = app_id: focus-or-spawn-action ''select(.app_id == "${app_id}")''; | ||
41 | |||
42 | with_adjacent_workspace = pkgs.writeShellApplication { | ||
43 | name = "with-adjacent-workspace"; | ||
44 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
45 | text = '' | ||
46 | blacklist="$1" | ||
47 | shift | ||
48 | direction="$1" | ||
49 | shift | ||
50 | action="$1" | ||
51 | shift | ||
52 | |||
53 | workspaces_json="$(niri msg -j workspaces)" | ||
54 | active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")" | ||
55 | workspace_output="$(jq -r --arg active_workspace "$active_workspace" '.[] | select(.id == ($active_workspace | tonumber)) | .output' <<<"$workspaces_json")" | ||
56 | workspace_idx="$(jq -r '.[] | select(.is_focused) | .idx' <<<"$workspaces_json")" | ||
57 | |||
58 | jq_script='map(select(' | ||
59 | case "$direction" in | ||
60 | down) | ||
61 | # shellcheck disable=SC2016 | ||
62 | jq_script=''${jq_script}'.idx > ($workspace_idx | tonumber)';; | ||
63 | up) | ||
64 | # shellcheck disable=SC2016 | ||
65 | jq_script=''${jq_script}'.idx < ($workspace_idx | tonumber)';; | ||
66 | esac | ||
67 | # shellcheck disable=SC2016 | ||
68 | jq_script=''${jq_script}' and .output == $workspace_output and ((.name == null) or (.name | test($blacklist) | not)))) | sort_by(.idx)' | ||
69 | [[ $direction == "up" ]] && jq_script=''${jq_script}' | reverse' | ||
70 | jq_script=''${jq_script}' | .[0]' | ||
71 | |||
72 | workspace_json=$(jq -c --arg blacklist "$blacklist" --arg workspace_output "$workspace_output" --arg workspace_idx "$workspace_idx" "$jq_script" <<<"$workspaces_json") | ||
73 | [[ -n $workspace_json && $workspace_json != null ]] || exit 0 | ||
74 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
75 | ''; | ||
76 | }; | ||
77 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^pwctl|eff|kpxc|bmgr|edit|term$"; | ||
78 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
79 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | ||
80 | |||
81 | with_unnamed_workspace = pkgs.writeShellApplication { | ||
82 | name = "with-unnamed-workspace"; | ||
83 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
84 | text = '' | ||
85 | action="$1" | ||
86 | shift | ||
87 | |||
88 | workspaces_json="$(niri msg -j workspaces)" | ||
89 | active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
90 | active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")" | ||
91 | |||
92 | workspace_json="$(jq -c --arg active_output "$active_output" 'map(select(.output == $active_output and .name == null)) | sort_by(.idx) | .[0]' <<<"$workspaces_json")" | ||
93 | [[ -n $workspace_json && $workspace_json != null ]] || exit 0 | ||
94 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
95 | ''; | ||
96 | }; | ||
97 | with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); | ||
98 | |||
99 | with_select_window = pkgs.writeShellApplication { | ||
100 | name = "with-select-window"; | ||
101 | runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; | ||
102 | text = '' | ||
103 | window_select="$1" | ||
104 | shift | ||
105 | action="$1" | ||
106 | shift | ||
107 | |||
108 | windows_json="$(niri msg -j windows)" | ||
109 | active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" | ||
110 | window_ix="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\u0000icon\u001f\(.app_id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu --index)" | ||
111 | # shellcheck disable=SC2016 | ||
112 | window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" | ||
113 | |||
114 | [[ -z "$window_json" ]] && exit 1 | ||
115 | |||
116 | jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" | ||
117 | ''; | ||
118 | }; | ||
119 | with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); | ||
38 | in { | 120 | in { |
39 | imports = [ | 121 | imports = [ |
40 | ./waybar.nix | 122 | ./waybar.nix |
123 | ./mako.nix | ||
124 | ./swayosd.nix | ||
41 | ]; | 125 | ]; |
42 | 126 | ||
43 | config = { | 127 | config = { |
@@ -79,10 +163,15 @@ in { | |||
79 | hotkey-overlay.skip-at-startup = true; | 163 | hotkey-overlay.skip-at-startup = true; |
80 | 164 | ||
81 | input = { | 165 | input = { |
82 | keyboard.xkb = { | 166 | keyboard = { |
83 | layout = "us,us"; | 167 | repeat-delay = 300; |
84 | variant = "dvp,"; | 168 | repeat-rate = 50; |
85 | options = "compose:caps,grp:win_space_toggle"; | 169 | |
170 | xkb = { | ||
171 | layout = "us,us"; | ||
172 | variant = "dvp,"; | ||
173 | options = "compose:caps,grp:win_space_toggle"; | ||
174 | }; | ||
86 | }; | 175 | }; |
87 | 176 | ||
88 | workspace-auto-back-and-forth = true; | 177 | workspace-auto-back-and-forth = true; |
@@ -91,7 +180,7 @@ in { | |||
91 | }; | 180 | }; |
92 | 181 | ||
93 | outputs = { | 182 | outputs = { |
94 | "Samsung Display Corp. 0x4141 Unknown" = { | 183 | "eDP-1" = { |
95 | scale = 1.5; | 184 | scale = 1.5; |
96 | position = { x = 0; y = 0; }; | 185 | position = { x = 0; y = 0; }; |
97 | }; | 186 | }; |
@@ -99,38 +188,94 @@ in { | |||
99 | scale = 1.5; | 188 | scale = 1.5; |
100 | position = { x = 2560; y = 0; }; | 189 | position = { x = 2560; y = 0; }; |
101 | }; | 190 | }; |
191 | "HP Inc. HP 727pu CN4417143K" = { | ||
192 | mode = { width = 2560; height = 1440; refresh = 119.998; }; | ||
193 | scale = 1; | ||
194 | position = { x = 2560; y = 0; }; | ||
195 | variable-refresh-rate = "on-demand"; | ||
196 | }; | ||
102 | }; | 197 | }; |
103 | 198 | ||
104 | environment = { | 199 | environment = { |
105 | NIXOS_OZONE_WL = "1"; | 200 | NIXOS_OZONE_WL = "1"; |
106 | QT_QPA_PLATFORM = "wayland"; | 201 | QT_QPA_PLATFORM = "wayland"; |
202 | QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; | ||
107 | GDK_BACKEND = "wayland"; | 203 | GDK_BACKEND = "wayland"; |
108 | SDL_VIDEODRIVER = "wayland"; | 204 | SDL_VIDEODRIVER = "wayland"; |
205 | DISPLAY = ":0"; | ||
206 | }; | ||
207 | |||
208 | debug.render-drm-device = "/dev/dri/by-path/pci-0000:00:02.0-render"; | ||
209 | |||
210 | animations = { | ||
211 | slowdown = 0.5; | ||
109 | }; | 212 | }; |
110 | 213 | ||
111 | layout = { | 214 | layout = { |
112 | gaps = 8; | 215 | gaps = 8; |
113 | struts = { left = 8; right = 8; top = 0; bottom = 0; }; | 216 | struts = { left = 0; right = 0; top = 0; bottom = 0; }; |
114 | focus-ring = { | 217 | focus-ring = { |
115 | width = 2; | 218 | width = 2; |
219 | active.gradient = { | ||
220 | from = "hsla(195 100% 60% 0.75)"; | ||
221 | to = "hsla(155 100% 50% 0.75)"; | ||
222 | angle = 29; | ||
223 | relative-to = "workspace-view"; | ||
224 | }; | ||
225 | inactive.gradient = { | ||
226 | from = "hsla(0 0% 42% 0.66)"; | ||
227 | to = "hsla(0 0% 35% 0.66)"; | ||
228 | angle = 29; | ||
229 | relative-to = "workspace-view"; | ||
230 | }; | ||
116 | }; | 231 | }; |
232 | |||
233 | preset-column-widths = [ | ||
234 | { proportion = 1. / 4.; } | ||
235 | { proportion = 1. / 3.; } | ||
236 | { proportion = 1. / 2.; } | ||
237 | { proportion = 2. / 3.; } | ||
238 | { proportion = 3. / 4.; } | ||
239 | ]; | ||
240 | default-column-width.proportion = 1. / 2.; | ||
241 | preset-window-heights = [ | ||
242 | { proportion = 1. / 3.; } | ||
243 | { proportion = 1. / 2.; } | ||
244 | { proportion = 2. / 3.; } | ||
245 | { proportion = 1.; } | ||
246 | ]; | ||
247 | |||
248 | always-center-single-column = true; | ||
117 | }; | 249 | }; |
118 | 250 | ||
119 | cursor.hide-when-typing = true; | 251 | cursor.hide-when-typing = true; |
120 | 252 | ||
253 | input = { | ||
254 | touchpad.enable = false; | ||
255 | trackball = { | ||
256 | scroll-method = "on-button-down"; | ||
257 | scroll-button = 278; | ||
258 | }; | ||
259 | }; | ||
260 | |||
121 | workspaces = { | 261 | workspaces = { |
122 | "001".name = "pwctl"; | 262 | "001" = { name = "pwctl"; open-on-output = "eDP-1"; }; |
123 | "002".name = "kpxc"; | 263 | "002" = { name = "kpxc"; open-on-output = "eDP-1"; }; |
124 | "003".name = "bmgr"; | 264 | "003" = { name = "bmgr"; open-on-output = "eDP-1"; }; |
265 | "004" = { name = "term"; open-on-output = "eDP-1"; }; | ||
266 | "005" = { name = "edit"; open-on-output = "eDP-1"; }; | ||
267 | "006" = { name = "eff"; open-on-output = "eDP-1"; }; | ||
125 | "101".name = "comm"; | 268 | "101".name = "comm"; |
126 | "102".name = "web"; | 269 | "102".name = "web"; |
127 | "104".name = "read"; | 270 | # "104".name = "read"; |
128 | "105".name = "mon"; | 271 | # "105".name = "mon"; |
129 | "110".name = "vid"; | 272 | "110".name = "vid"; |
273 | "120".name = "bmr"; | ||
130 | }; | 274 | }; |
131 | 275 | ||
132 | window-rules = [ | 276 | window-rules = [ |
133 | { | 277 | { |
278 | matches = [ { is-floating = true; } ]; | ||
134 | geometry-corner-radius = | 279 | geometry-corner-radius = |
135 | let | 280 | let |
136 | allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; }; | 281 | allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; }; |
@@ -140,50 +285,130 @@ in { | |||
140 | { | 285 | { |
141 | matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ]; | 286 | matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ]; |
142 | open-on-workspace = "pwctl"; | 287 | open-on-workspace = "pwctl"; |
288 | open-maximized = true; | ||
289 | } | ||
290 | { | ||
291 | matches = [ { app-id = "^com\.github\.wwmm\.easyeffects$"; } ]; | ||
292 | open-on-workspace = "eff"; | ||
293 | open-maximized = true; | ||
143 | } | 294 | } |
144 | { | 295 | { |
145 | matches = [ { app-id = "^\.blueman-manager-wrapped$"; } ]; | 296 | matches = [ { app-id = "^\.blueman-manager-wrapped$"; } ]; |
146 | open-on-workspace = "bmgr"; | 297 | open-on-workspace = "bmgr"; |
298 | open-maximized = true; | ||
299 | } | ||
300 | { | ||
301 | matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; } ]; | ||
302 | block-out-from = "screencast"; | ||
147 | } | 303 | } |
148 | { | 304 | { |
149 | matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; } ]; | 305 | matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; } ]; |
150 | excludes = [ | 306 | excludes = [ |
151 | { title = "^Unlock Database"; } | 307 | { title = "^Unlock Database.*"; } |
152 | { title = "^Access Request"; } | 308 | { title = "^Access Request.*"; } |
153 | { title = "^Passkey credentials"; } | 309 | { title = ".*Passkey credentials$"; } |
154 | ]; | 310 | ]; |
155 | open-on-workspace = "kpxc"; | 311 | open-on-workspace = "kpxc"; |
312 | open-maximized = true; | ||
156 | open-focused = false; | 313 | open-focused = false; |
157 | } | 314 | } |
158 | { | 315 | { |
159 | matches = [ | 316 | matches = [ |
317 | { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Unlock Database.*"; } | ||
318 | { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Access Request.*"; } | ||
319 | { app-id = "^org\.keepassxc\.KeePassXC$"; title = ".*Passkey credentials$"; } | ||
320 | ]; | ||
321 | open-focused = true; | ||
322 | open-floating = true; | ||
323 | } | ||
324 | { | ||
325 | matches = [ { app-id = "^kitty-scratch$"; } ]; | ||
326 | open-on-workspace = "term"; | ||
327 | open-maximized = true; | ||
328 | } | ||
329 | { | ||
330 | matches = [ { title = "^scratch$"; app-id = "^emacs$"; } ]; | ||
331 | open-on-workspace = "edit"; | ||
332 | open-maximized = true; | ||
333 | } | ||
334 | { | ||
335 | matches = [ | ||
336 | { app-id = "^emacs$"; } | ||
337 | { app-id = "^firefox$"; } | ||
338 | ]; | ||
339 | default-column-width.proportion = 2. / 3.; | ||
340 | } | ||
341 | { | ||
342 | matches = [ | ||
343 | { app-id = "^kitty$"; } | ||
344 | { app-id = "^kitty-play$"; } | ||
345 | ]; | ||
346 | default-column-width.proportion = 1. / 3.; | ||
347 | } | ||
348 | { | ||
349 | matches = [ | ||
160 | { app-id = "^thunderbird$"; } | 350 | { app-id = "^thunderbird$"; } |
161 | { app-id = "^Element$"; } | 351 | { app-id = "^Element$"; } |
352 | { app-id = "^Rainbow$"; } | ||
162 | ]; | 353 | ]; |
163 | open-on-workspace = "comm"; | 354 | open-on-workspace = "comm"; |
164 | } | 355 | } |
165 | { | 356 | { |
166 | matches = [ { app-id = "^firefox$"; } ]; | 357 | matches = [ { app-id = "^firefox$"; } ]; |
167 | open-on-workspace = "web"; | 358 | open-on-workspace = "web"; |
359 | open-maximized = true; | ||
360 | variable-refresh-rate = true; | ||
168 | } | 361 | } |
362 | # { | ||
363 | # matches = [ | ||
364 | # { app-id = "^evince$"; } | ||
365 | # { app-id = "^imv$"; } | ||
366 | # { app-id = "^org\.pwmt\.zathura$"; } | ||
367 | # ]; | ||
368 | # open-on-workspace = "read"; | ||
369 | # } | ||
169 | { | 370 | { |
170 | matches = [ | 371 | matches = [ { app-id = "^mpv$"; } ]; |
171 | { app-id = "^evince$"; } | 372 | open-on-workspace = "vid"; |
172 | { app-id = "^imv$"; } | 373 | default-column-width.proportion = 1.; |
173 | { app-id = "^org\.pwmt\.zathura$"; } | 374 | variable-refresh-rate = true; |
174 | ]; | ||
175 | open-on-workspace = "read"; | ||
176 | } | 375 | } |
177 | { | 376 | { |
178 | matches = [ { app-id = "^mpv$"; } ]; | 377 | matches = [ { app-id = "^kitty-play$"; } ]; |
179 | open-on-workspace = "vid"; | 378 | open-on-workspace = "vid"; |
379 | open-focused = false; | ||
380 | } | ||
381 | # { | ||
382 | # matches = [ | ||
383 | # { app-id = "^qemu$"; } | ||
384 | # { app-id = "^virt-manager$"; } | ||
385 | # ]; | ||
386 | # open-on-workspace = "mon"; | ||
387 | # } | ||
388 | { | ||
389 | matches = [ { app-id = "^pdfpc$"; } ]; | ||
390 | default-column-width.proportion = 1.; | ||
391 | } | ||
392 | { | ||
393 | matches = [ { app-id = "^pdfpc$"; title = "^pdfpc - presentation"; } ]; | ||
394 | open-on-workspace = "bmr"; | ||
395 | open-fullscreen = true; | ||
180 | } | 396 | } |
181 | { | 397 | { |
182 | matches = [ | 398 | matches = [ |
183 | { app-id = "^qemu$"; } | 399 | { app-id = "^Gimp-"; title = "^Quit GIMP$"; } |
184 | { app-id = "^virt-manager$"; } | 400 | { app-id = "^org\.kde\.polkit-kde-authentication-agent-1$"; } |
401 | { app-id = "^xdg-desktop-portal-gtk$"; } | ||
185 | ]; | 402 | ]; |
186 | open-on-workspace = "mon"; | 403 | open-floating = true; |
404 | } | ||
405 | ]; | ||
406 | layer-rules = [ | ||
407 | { matches = [ | ||
408 | { namespace = "^notifications$"; } | ||
409 | { namespace = "^waybar$"; } | ||
410 | ]; | ||
411 | block-out-from = "screencast"; | ||
187 | } | 412 | } |
188 | ]; | 413 | ]; |
189 | 414 | ||
@@ -192,8 +417,93 @@ in { | |||
192 | 417 | ||
193 | "Mod+Return".action = spawn terminal; | 418 | "Mod+Return".action = spawn terminal; |
194 | "Mod+Q".action = close-window; | 419 | "Mod+Q".action = close-window; |
195 | "Mod+D".action = spawn (lib.getExe config.programs.fuzzel.package); | 420 | "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); |
196 | "Mod+Shift+D".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; | 421 | "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; |
422 | |||
423 | "Mod+Alt+E".action = spawn (lib.getExe' config.services.emacs.package "emacsclient") "-c"; | ||
424 | "Mod+Alt+Y".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
425 | name = "queue-yt-dlp"; | ||
426 | runtimeInputs = with pkgs; [ wl-clipboard-rs socat ]; | ||
427 | text = '' | ||
428 | socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' | ||
429 | ''; | ||
430 | })); | ||
431 | "Mod+Alt+L".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
432 | name = "queue-yt-dlp"; | ||
433 | runtimeInputs = with pkgs; [ wl-clipboard-rs config.programs.kitty.package ]; | ||
434 | text = '' | ||
435 | exec -- kitty --app-id kitty-play --directory "$HOME"/media mpv "$(wl-paste)" | ||
436 | ''; | ||
437 | })); | ||
438 | |||
439 | "Mod+U".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
440 | name = "qalc-fuzzel"; | ||
441 | runtimeInputs = with pkgs; [ wl-clipboard-rs libqalculate config.programs.fuzzel.package coreutils findutils libnotify gnugrep ]; | ||
442 | text = '' | ||
443 | RESULTS_DIR="$HOME/.cache/qalc-fuzzel" | ||
444 | prev() { | ||
445 | FOUND=false | ||
446 | while IFS= read -r line; do | ||
447 | [[ -n "$line" ]] || continue | ||
448 | FOUND=true | ||
449 | echo "$line" | ||
450 | done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) | ||
451 | $FOUND || echo | ||
452 | } | ||
453 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? | ||
454 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then | ||
455 | QALC_RES="$FUZZEL_RES" | ||
456 | QALC_RET=0 | ||
457 | else | ||
458 | QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) | ||
459 | QALC_RET=$? | ||
460 | fi | ||
461 | [[ -n "$QALC_RES" ]] || exit 1 | ||
462 | EXISTING=false | ||
463 | set +o pipefail | ||
464 | grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch | ||
465 | [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true | ||
466 | set -o pipefail | ||
467 | if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then | ||
468 | set +o pipefail | ||
469 | RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10) | ||
470 | set -o pipefail | ||
471 | cat >"$RES_FILE" <<<"$QALC_RES" | ||
472 | fi | ||
473 | [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" | ||
474 | [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" | ||
475 | notify-send "$QALC_RES" | ||
476 | ''; | ||
477 | })); | ||
478 | "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
479 | name = "emoji-fuzzel"; | ||
480 | runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ]; | ||
481 | text = '' | ||
482 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <"$HOME"/.local/share/emoji-data/list.txt) || exit $? | ||
483 | [[ -n "$FUZZEL_RES" ]] || exit 1 | ||
484 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste | ||
485 | ''; | ||
486 | })); | ||
487 | "Print".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
488 | name = "screenshot"; | ||
489 | runtimeInputs = with pkgs; [ grim slurp wl-clipboard-rs coreutils ]; | ||
490 | text = '' | ||
491 | grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" - \ | ||
492 | | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ | ||
493 | | wl-copy --type image/png | ||
494 | ''; | ||
495 | })); | ||
496 | "Shift+Print".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
497 | name = "screenshot"; | ||
498 | runtimeInputs = with pkgs; [ grim niri gojq wl-clipboard-rs coreutils ]; | ||
499 | text = '' | ||
500 | grim -o "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" - \ | ||
501 | | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ | ||
502 | | wl-copy --type image/png | ||
503 | ''; | ||
504 | })); | ||
505 | "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
506 | "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
197 | 507 | ||
198 | "Mod+H".action = focus-column-left; | 508 | "Mod+H".action = focus-column-left; |
199 | "Mod+T".action = focus-window-down; | 509 | "Mod+T".action = focus-window-down; |
@@ -215,15 +525,33 @@ in { | |||
215 | "Mod+Shift+Control+N".action = move-workspace-to-monitor-up; | 525 | "Mod+Shift+Control+N".action = move-workspace-to-monitor-up; |
216 | "Mod+Shift+Control+S".action = move-workspace-to-monitor-right; | 526 | "Mod+Shift+Control+S".action = move-workspace-to-monitor-right; |
217 | 527 | ||
218 | "Mod+G".action = focus-workspace-down; | 528 | "Mod+G".action = focus-adjacent-workspace "down"; |
219 | "Mod+C".action = focus-workspace-up; | 529 | "Mod+C".action = focus-adjacent-workspace "up"; |
220 | 530 | ||
221 | "Mod+Shift+G".action = move-column-to-workspace-down; | 531 | "Mod+Shift+G".action = move-column-to-adjacent-workspace "down"; |
222 | "Mod+Shift+C".action = move-column-to-workspace-up; | 532 | "Mod+Shift+C".action = move-column-to-adjacent-workspace "up"; |
223 | 533 | ||
224 | "Mod+Shift+Control+G".action = move-workspace-down; | 534 | "Mod+Shift+Control+G".action = move-workspace-down; |
225 | "Mod+Shift+Control+C".action = move-workspace-up; | 535 | "Mod+Shift+Control+C".action = move-workspace-up; |
226 | 536 | ||
537 | "Mod+ParenLeft".action = focus-workspace "comm"; | ||
538 | "Mod+Shift+ParenLeft".action = move-column-to-workspace "comm"; | ||
539 | |||
540 | "Mod+ParenRight".action = focus-workspace "web"; | ||
541 | "Mod+Shift+ParenRight".action = move-column-to-workspace "web"; | ||
542 | |||
543 | "Mod+BraceRight".action = focus-workspace "read"; | ||
544 | "Mod+Shift+BraceRight".action = move-column-to-workspace "read"; | ||
545 | |||
546 | "Mod+BraceLeft".action = focus-workspace "mon"; | ||
547 | "Mod+Shift+BraceLeft".action = move-column-to-workspace "mon"; | ||
548 | |||
549 | "Mod+Asterisk".action = focus-workspace "vid"; | ||
550 | "Mod+Shift+Asterisk".action = move-column-to-workspace "vid"; | ||
551 | |||
552 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
553 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | ||
554 | |||
227 | "Mod+M".action = consume-or-expel-window-left; | 555 | "Mod+M".action = consume-or-expel-window-left; |
228 | "Mod+W".action = consume-or-expel-window-right; | 556 | "Mod+W".action = consume-or-expel-window-right; |
229 | 557 | ||
@@ -233,8 +561,8 @@ in { | |||
233 | "Mod+Shift+F".action = maximize-column; | 561 | "Mod+Shift+F".action = maximize-column; |
234 | "Mod+Shift+Ctrl+F".action = fullscreen-window; | 562 | "Mod+Shift+Ctrl+F".action = fullscreen-window; |
235 | 563 | ||
236 | "Mod+B".action = switch-focus-between-floating-and-tiling; | 564 | "Mod+V".action = switch-focus-between-floating-and-tiling; |
237 | "Mod+Shift+B".action = toggle-window-floating; | 565 | "Mod+Shift+V".action = toggle-window-floating; |
238 | 566 | ||
239 | "Mod+Left".action = set-column-width "-10%"; | 567 | "Mod+Left".action = set-column-width "-10%"; |
240 | "Mod+Down".action = set-window-height "-10%"; | 568 | "Mod+Down".action = set-window-height "-10%"; |
@@ -245,44 +573,57 @@ in { | |||
245 | action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; | 573 | action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; |
246 | allow-when-locked = true; | 574 | allow-when-locked = true; |
247 | }; | 575 | }; |
248 | "Mod+Shift+L" = { | 576 | "Mod+Shift+L".action = spawn loginctl "lock-session"; |
249 | action = spawn loginctl "lock-session"; | ||
250 | }; | ||
251 | "Mod+Shift+E".action = quit; | 577 | "Mod+Shift+E".action = quit; |
578 | "Mod+Shift+Minus" = { | ||
579 | action = spawn systemctl "suspend"; | ||
580 | allow-when-locked = true; | ||
581 | }; | ||
582 | "Mod+Shift+Control+Minus" = { | ||
583 | action = spawn systemctl "hibernate"; | ||
584 | allow-when-locked = true; | ||
585 | }; | ||
586 | "Mod+Shift+P" = { | ||
587 | action = spawn (lib.getExe pkgs.playerctl) "-a" "pause"; | ||
588 | allow-when-locked = true; | ||
589 | }; | ||
252 | 590 | ||
253 | "XF86MonBrightnessUp" = { | 591 | "XF86MonBrightnessUp" = { |
254 | action = spawn lightctl "-d" "-e4" "-n1" "up"; | 592 | action = spawn swayosd-client "--brightness" "raise"; |
255 | allow-when-locked = true; | 593 | allow-when-locked = true; |
256 | }; | 594 | }; |
257 | "XF86MonBrightnessDown" = { | 595 | "XF86MonBrightnessDown" = { |
258 | action = spawn lightctl "-d" "-e4" "-n1" "down"; | 596 | action = spawn swayosd-client "--brightness" "lower"; |
259 | allow-when-locked = true; | 597 | allow-when-locked = true; |
260 | }; | 598 | }; |
261 | "XF86AudioRaiseVolume" = { | 599 | "XF86AudioRaiseVolume" = { |
262 | action = spawn volumectl "-d" "-u" "up"; | 600 | action = spawn swayosd-client "--output-volume" "raise"; |
263 | allow-when-locked = true; | 601 | allow-when-locked = true; |
264 | }; | 602 | }; |
265 | "XF86AudioLowerVolume" = { | 603 | "XF86AudioLowerVolume" = { |
266 | action = spawn volumectl "-d" "-u" "down"; | 604 | action = spawn swayosd-client "--output-volume" "lower"; |
267 | allow-when-locked = true; | 605 | allow-when-locked = true; |
268 | }; | 606 | }; |
269 | "XF86AudioMute" = { | 607 | "XF86AudioMute" = { |
270 | action = spawn volumectl "-d" "toggle-mute"; | 608 | action = spawn swayosd-client "--output-volume" "mute-toggle"; |
271 | allow-when-locked = true; | 609 | allow-when-locked = true; |
272 | }; | 610 | }; |
273 | "XF86AudioMicMute" = { | 611 | "XF86AudioMicMute" = { |
274 | action = spawn volumectl "-d" "-m" "toggle-mute"; | 612 | action = spawn swayosd-client "--input-volume" "mute-toggle"; |
275 | allow-when-locked = true; | 613 | allow-when-locked = true; |
276 | }; | 614 | }; |
277 | 615 | ||
278 | "Mod+Semicolon".action = spawn dunstctl "close"; | 616 | "Mod+Semicolon".action = spawn makoctl "dismiss" "--group"; |
279 | "Mod+Shift+Semicolon".action = spawn dunstctl "close-all"; | 617 | "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; |
280 | "Mod+Period".action = spawn dunstctl "context"; | 618 | "Mod+Period".action = spawn makoctl "menu" (lib.getExe config.programs.fuzzel.package) "--dmenu"; |
281 | "Mod+Comma".action = spawn dunstctl "history-pop"; | 619 | "Mod+Comma".action = spawn makoctl "restore"; |
282 | 620 | ||
283 | "Mod+Alt+A".action = focus-or-spawn-action "^com\.saivert\.pwvucontrol$" "pwctl" "pwvucontrol"; | 621 | "Mod+Control+A".action = focus-or-spawn-action-app_id "com.saivert.pwvucontrol" "pwctl" "pwvucontrol"; |
284 | "Mod+Alt+P".action = focus-or-spawn-action "^org\.keepassxc\.KeePassXC$" "kpxc" "keepassxc"; | 622 | "Mod+Control+O".action = focus-or-spawn-action-app_id "com.github.wwmm.easyeffects" "eff" "easyeffects"; |
285 | "Mod+Alt+B".action = focus-or-spawn-action "^\.blueman-manager-wrapped$" "bmgr" "blueman-manager"; | 623 | "Mod+Control+P".action = focus-or-spawn-action-app_id "org.keepassxc.KeePassXC" "kpxc" "keepassxc"; |
624 | "Mod+Control+B".action = focus-or-spawn-action-app_id ".blueman-manager-wrapped" "bmgr" "blueman-manager"; | ||
625 | "Mod+Control+Return".action = focus-or-spawn-action-app_id "kitty-scratch" "term" "kitty" "--app-id" "kitty-scratch"; | ||
626 | "Mod+Control+E".action = focus-or-spawn-action "select(.app_id == \"emacs\" and .title == \"scratch\")" "edit" "emacsclient" "-c" "--frame-parameters=(quote (name . \"scratch\"))"; | ||
286 | }; | 627 | }; |
287 | }; | 628 | }; |
288 | }; | 629 | }; |