summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/niri
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/niri')
-rw-r--r--accounts/gkleen@sif/niri/default.nix536
-rw-r--r--accounts/gkleen@sif/niri/mako.nix50
-rw-r--r--accounts/gkleen@sif/niri/waybar.nix338
3 files changed, 0 insertions, 924 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
deleted file mode 100644
index 0c4a58e5..00000000
--- a/accounts/gkleen@sif/niri/default.nix
+++ /dev/null
@@ -1,536 +0,0 @@
1{ config, hostConfig, pkgs, lib, ... }:
2let
3 niri = config.programs.niri.package;
4 terminal = lib.getExe config.programs.kitty.package;
5 lightctl = lib.getExe' config.services.avizo.package "lightctl";
6 volumectl = lib.getExe' config.services.avizo.package "volumectl";
7 makoctl = lib.getExe' config.services.mako.package "makoctl";
8 loginctl = lib.getExe' hostConfig.systemd.package "loginctl";
9 systemctl = lib.getExe' hostConfig.systemd.package "systemctl";
10
11 focus_or_spawn = pkgs.writeShellApplication {
12 name = "focus-or-spawn";
13 runtimeInputs = [ niri pkgs.gojq pkgs.gnugrep pkgs.socat ];
14 text = ''
15 window_select="$1"
16 shift
17 workspace_name="$1"
18 shift
19
20 workspaces_json="$(niri msg -j workspaces)"
21 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")"
23 active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")"
24 if [[ $workspace_output != "$active_output" ]]; then
25 niri msg action move-workspace-to-monitor --output "$active_output" "$workspace_name"
26 socat STDIO "$NIRI_SOCKET" <<<'{"Action":{"FocusWorkspace":{"reference":{"Id":'"''${active_workspace}"'}}}}'
27 niri msg action move-workspace-to-index --index 1 "$workspace_name"
28 fi
29
30 while IFS=$'\n' read -r window_json; do
31 if [[ -n $(jq -c "$window_select" <<<"$window_json") ]]; then
32 niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")"
33 exit 0
34 fi
35 done < <(niri msg -j windows | jq -c '.[]')
36
37 exec "$@"
38 '';
39 };
40 focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn);
41 focus-or-spawn-action-app_id = app_id: focus-or-spawn-action ''select(.app_id == "${app_id}")'';
42
43 with_adjacent_workspace = pkgs.writeShellApplication {
44 name = "with-adjacent-workspace";
45 runtimeInputs = [ niri pkgs.gojq pkgs.socat ];
46 text = ''
47 blacklist="$1"
48 shift
49 direction="$1"
50 shift
51 action="$1"
52 shift
53
54 workspaces_json="$(niri msg -j workspaces)"
55 active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")"
56 workspace_output="$(jq -r --arg active_workspace "$active_workspace" '.[] | select(.id == ($active_workspace | tonumber)) | .output' <<<"$workspaces_json")"
57 workspace_idx="$(jq -r '.[] | select(.is_focused) | .idx' <<<"$workspaces_json")"
58
59 jq_script='map(select('
60 case "$direction" in
61 down)
62 # shellcheck disable=SC2016
63 jq_script=''${jq_script}'.idx > ($workspace_idx | tonumber)';;
64 up)
65 # shellcheck disable=SC2016
66 jq_script=''${jq_script}'.idx < ($workspace_idx | tonumber)';;
67 esac
68 # shellcheck disable=SC2016
69 jq_script=''${jq_script}' and .output == $workspace_output and ((.name == null) or (.name | test($blacklist) | not)))) | sort_by(.idx)'
70 [[ $direction == "up" ]] && jq_script=''${jq_script}' | reverse'
71 jq_script=''${jq_script}' | .[0]'
72
73 workspace_json=$(jq -c --arg blacklist "$blacklist" --arg workspace_output "$workspace_output" --arg workspace_idx "$workspace_idx" "$jq_script" <<<"$workspaces_json")
74 [[ -n $workspace_json && $workspace_json != null ]] || exit 0
75 jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET"
76 '';
77 };
78 with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^pwctl|kpxc|bmgr|edit|term$";
79 focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}'';
80 move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}'';
81
82 with_unnamed_workspace = pkgs.writeShellApplication {
83 name = "with-unnamed-workspace";
84 runtimeInputs = [ niri pkgs.gojq pkgs.socat ];
85 text = ''
86 action="$1"
87 shift
88
89 workspaces_json="$(niri msg -j workspaces)"
90 active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")"
91 active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")"
92
93 workspace_json="$(jq -c --arg active_output "$active_output" 'map(select(.output == $active_output and .name == null)) | sort_by(.idx) | .[0]' <<<"$workspaces_json")"
94 [[ -n $workspace_json && $workspace_json != null ]] || exit 0
95 jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET"
96 '';
97 };
98 with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace);
99
100 with_select_window = pkgs.writeShellApplication {
101 name = "with-unnamed-workspace";
102 runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ];
103 text = ''
104 window_select="$1"
105 shift
106 action="$1"
107 shift
108
109 windows_json="$(niri msg -j windows)"
110 active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")"
111 window="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\t\(.id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu)"
112 window_id="$(awk -F $'\t' '{print $2}' <<<"$window")"
113 window_json="$(jq -r --arg window_id "$window_id" '.[] | select(.id == ($window_id | tonumber))' <<<"$windows_json")"
114
115 [[ -z "$window_json" ]] && exit 1
116
117 jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET"
118 '';
119 };
120 with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window);
121in {
122 imports = [
123 ./waybar.nix
124 ./mako.nix
125 ];
126
127 config = {
128 systemd.user.services.xwayland-satellite = {
129 Unit = {
130 BindsTo = [ "graphical-session.target" ];
131 PartOf = [ "graphical-session.target" ];
132 After = [ "graphical-session.target" ];
133 Requisite = [ "graphical-session.target" ];
134 };
135 Service = {
136 Type = "notify";
137 NotifyAccess = "all";
138 Environment = [ "DISPLAY=:0" ];
139 ExecStart = ''${lib.getExe pkgs.xwayland-satellite-unstable} ''${DISPLAY}'';
140 ExecStartPre = "${systemctl} --user import-environment DISPLAY";
141 StandardOutput = "journal";
142 };
143 Install = {
144 WantedBy = [ "graphical-session.target" ];
145 };
146 };
147
148 services.swayidle = {
149 events = [
150 { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; }
151 ];
152 timeouts = [
153 { timeout = 300;
154 command = "${lib.getExe niri} msg action power-off-monitors";
155 }
156 ];
157 };
158
159 programs.niri.settings = {
160 prefer-no-csd = true;
161 screenshot-path = "${config.home.homeDirectory}/screenshots";
162
163 hotkey-overlay.skip-at-startup = true;
164
165 input = {
166 keyboard.xkb = {
167 layout = "us,us";
168 variant = "dvp,";
169 options = "compose:caps,grp:win_space_toggle";
170 };
171
172 workspace-auto-back-and-forth = true;
173 # focus-follows-mouse.enable = true;
174 warp-mouse-to-focus = true;
175 };
176
177 outputs = {
178 "eDP-1" = {
179 scale = 1.5;
180 position = { x = 0; y = 0; };
181 };
182 "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" = {
183 scale = 1.5;
184 position = { x = 2560; y = 0; };
185 };
186 };
187
188 environment = {
189 NIXOS_OZONE_WL = "1";
190 QT_QPA_PLATFORM = "wayland";
191 GDK_BACKEND = "wayland";
192 SDL_VIDEODRIVER = "wayland";
193 };
194
195 layout = {
196 gaps = 8;
197 struts = { left = 0; right = 0; top = 0; bottom = 0; };
198 focus-ring = {
199 width = 2;
200 active.gradient = {
201 from = "hsla(195 100% 60% 0.75)";
202 to = "hsla(155 100% 50% 0.75)";
203 angle = 29;
204 relative-to = "workspace-view";
205 };
206 inactive.gradient = {
207 from = "hsla(0 0% 42% 0.66)";
208 to = "hsla(0 0% 35% 0.66)";
209 angle = 29;
210 relative-to = "workspace-view";
211 };
212 };
213
214 preset-column-widths = [
215 { proportion = 1. / 4.; }
216 { proportion = 1. / 3.; }
217 { proportion = 1. / 2.; }
218 { proportion = 2. / 3.; }
219 { proportion = 3. / 4.; }
220 ];
221 default-column-width.proportion = 1. / 2.;
222 preset-window-heights = [
223 { proportion = 1. / 3.; }
224 { proportion = 1. / 2.; }
225 { proportion = 2. / 3.; }
226 { proportion = 1.; }
227 ];
228
229 always-center-single-column = true;
230 };
231
232 cursor.hide-when-typing = true;
233
234 workspaces = {
235 "001" = { name = "pwctl"; open-on-output = "eDP-1"; };
236 "002" = { name = "kpxc"; open-on-output = "eDP-1"; };
237 "003" = { name = "bmgr"; open-on-output = "eDP-1"; };
238 "004" = { name = "term"; open-on-output = "eDP-1"; };
239 "005" = { name = "edit"; open-on-output = "eDP-1"; };
240 "101".name = "comm";
241 "102".name = "web";
242 # "104".name = "read";
243 # "105".name = "mon";
244 "110".name = "vid";
245 };
246
247 window-rules = [
248 # {
249 # geometry-corner-radius =
250 # let
251 # allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; };
252 # in allCorners 4.;
253 # clip-to-geometry = true;
254 # }
255 {
256 matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ];
257 open-on-workspace = "pwctl";
258 }
259 {
260 matches = [ { app-id = "^\.blueman-manager-wrapped$"; } ];
261 open-on-workspace = "bmgr";
262 }
263 {
264 matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; } ];
265 excludes = [
266 { title = "^Unlock Database.*"; }
267 { title = "^Access Request.*"; }
268 { title = ".*Passkey credentials$"; }
269 ];
270 open-on-workspace = "kpxc";
271 open-focused = false;
272 }
273 {
274 matches = [
275 { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Unlock Database.*"; }
276 { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Access Request.*"; }
277 { app-id = "^org\.keepassxc\.KeePassXC$"; title = ".*Passkey credentials$"; }
278 ];
279 open-focused = true;
280 }
281 {
282 matches = [ { app-id = "^kitty-scratch$"; } ];
283 open-on-workspace = "term";
284 }
285 {
286 matches = [ { title = "^scratch$"; app-id = "^emacs$"; } ];
287 open-on-workspace = "edit";
288 }
289 {
290 matches = [
291 { app-id = "^thunderbird$"; }
292 { app-id = "^Element$"; }
293 ];
294 open-on-workspace = "comm";
295 }
296 {
297 matches = [ { app-id = "^firefox$"; } ];
298 open-on-workspace = "web";
299 }
300 # {
301 # matches = [
302 # { app-id = "^evince$"; }
303 # { app-id = "^imv$"; }
304 # { app-id = "^org\.pwmt\.zathura$"; }
305 # ];
306 # open-on-workspace = "read";
307 # }
308 {
309 matches = [ { app-id = "^mpv$"; } ];
310 open-on-workspace = "vid";
311 default-column-width.proportion = 1.;
312 }
313 {
314 matches = [ { app-id = "^kitty-play$"; } ];
315 open-on-workspace = "vid";
316 default-column-width.proportion = 1. / 3.;
317 open-focused = false;
318 }
319 # {
320 # matches = [
321 # { app-id = "^qemu$"; }
322 # { app-id = "^virt-manager$"; }
323 # ];
324 # open-on-workspace = "mon";
325 # }
326 ];
327
328 binds = with config.lib.niri.actions; {
329 "Mod+Slash".action = show-hotkey-overlay;
330
331 "Mod+Return".action = spawn terminal;
332 "Mod+Q".action = close-window;
333 "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package);
334 "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path";
335
336 "Mod+Alt+E".action = spawn (lib.getExe' config.services.emacs.package "emacsclient") "-c";
337 "Mod+Alt+Y".action = spawn (lib.getExe (pkgs.writeShellApplication {
338 name = "queue-yt-dlp";
339 runtimeInputs = with pkgs; [ wl-clipboard-rs socat ];
340 text = ''
341 socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }'
342 '';
343 }));
344 "Mod+Alt+L".action = spawn (lib.getExe (pkgs.writeShellApplication {
345 name = "queue-yt-dlp";
346 runtimeInputs = with pkgs; [ wl-clipboard-rs config.programs.kitty.package ];
347 text = ''
348 exec -- kitty --app-id kitty-play --directory "$HOME"/media mpv "$(wl-paste)"
349 '';
350 }));
351
352 "Mod+U".action = spawn (lib.getExe (pkgs.writeShellApplication {
353 name = "qalc-fuzzel";
354 runtimeInputs = with pkgs; [ wl-clipboard-rs libqalculate config.programs.fuzzel.package coreutils findutils libnotify gnugrep ];
355 text = ''
356 RESULTS_DIR="$HOME/.cache/qalc-fuzzel"
357 prev() {
358 FOUND=false
359 while IFS= read -r line; do
360 [[ -n "$line" ]] || continue
361 FOUND=true
362 echo "$line"
363 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)
364 $FOUND || echo
365 }
366 FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $?
367 if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then
368 QALC_RES="$FUZZEL_RES"
369 QALC_RET=0
370 else
371 QALC_RES=$(qalc "$FUZZEL_RES" 2>&1)
372 QALC_RET=$?
373 fi
374 [[ -n "$QALC_RES" ]] || exit 1
375 EXISTING=false
376 set +e
377 grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch
378 [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true
379 set -e
380 if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then
381 RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10)
382 cat >"$RES_FILE" <<<"$QALC_RES"
383 fi
384 [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}"
385 [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES"
386 notify-send "$QALC_RES"
387 '';
388 }));
389 "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication {
390 name = "emoji-fuzzel";
391 runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ];
392 text = ''
393 FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <"$HOME"/.local/share/emoji-data/list.txt) || exit $?
394 [[ -n "$FUZZEL_RES" ]] || exit 1
395 wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste
396 '';
397 }));
398 "Print".action = spawn (lib.getExe (pkgs.writeShellApplication {
399 name = "screenshot";
400 runtimeInputs = with pkgs; [ grim slurp wl-clipboard-rs coreutils ];
401 text = ''
402 grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" - \
403 | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \
404 | wl-copy --type image/png
405 '';
406 }));
407 "Shift+Print".action = spawn (lib.getExe (pkgs.writeShellApplication {
408 name = "screenshot";
409 runtimeInputs = with pkgs; [ grim niri gojq wl-clipboard-rs coreutils ];
410 text = ''
411 grim -o "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" - \
412 | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \
413 | wl-copy --type image/png
414 '';
415 }));
416 "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}";
417 "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}";
418
419 "Mod+H".action = focus-column-left;
420 "Mod+T".action = focus-window-down;
421 "Mod+N".action = focus-window-up;
422 "Mod+S".action = focus-column-right;
423
424 "Mod+Shift+H".action = move-column-left;
425 "Mod+Shift+T".action = move-window-down;
426 "Mod+Shift+N".action = move-window-up;
427 "Mod+Shift+S".action = move-column-right;
428
429 "Mod+Control+H".action = focus-monitor-left;
430 "Mod+Control+T".action = focus-monitor-down;
431 "Mod+Control+N".action = focus-monitor-up;
432 "Mod+Control+S".action = focus-monitor-right;
433
434 "Mod+Shift+Control+H".action = move-workspace-to-monitor-left;
435 "Mod+Shift+Control+T".action = move-workspace-to-monitor-down;
436 "Mod+Shift+Control+N".action = move-workspace-to-monitor-up;
437 "Mod+Shift+Control+S".action = move-workspace-to-monitor-right;
438
439 "Mod+G".action = focus-adjacent-workspace "down";
440 "Mod+C".action = focus-adjacent-workspace "up";
441
442 "Mod+Shift+G".action = move-column-to-adjacent-workspace "down";
443 "Mod+Shift+C".action = move-column-to-adjacent-workspace "up";
444
445 "Mod+Shift+Control+G".action = move-workspace-down;
446 "Mod+Shift+Control+C".action = move-workspace-up;
447
448 "Mod+ParenLeft".action = focus-workspace "comm";
449 "Mod+Shift+ParenLeft".action = move-column-to-workspace "comm";
450
451 "Mod+ParenRight".action = focus-workspace "web";
452 "Mod+Shift+ParenRight".action = move-column-to-workspace "web";
453
454 "Mod+BraceRight".action = focus-workspace "read";
455 "Mod+Shift+BraceRight".action = move-column-to-workspace "read";
456
457 "Mod+BraceLeft".action = focus-workspace "mon";
458 "Mod+Shift+BraceLeft".action = move-column-to-workspace "mon";
459
460 "Mod+Asterisk".action = focus-workspace "vid";
461 "Mod+Shift+Asterisk".action = move-column-to-workspace "vid";
462
463 "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}'';
464 "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}'';
465
466 "Mod+M".action = consume-or-expel-window-left;
467 "Mod+W".action = consume-or-expel-window-right;
468
469 "Mod+R".action = switch-preset-column-width;
470 "Mod+Shift+R".action = switch-preset-window-height;
471 "Mod+F".action = center-column;
472 "Mod+Shift+F".action = maximize-column;
473 "Mod+Shift+Ctrl+F".action = fullscreen-window;
474
475 "Mod+V".action = switch-focus-between-floating-and-tiling;
476 "Mod+Shift+V".action = toggle-window-floating;
477
478 "Mod+Left".action = set-column-width "-10%";
479 "Mod+Down".action = set-window-height "-10%";
480 "Mod+Up".action = set-window-height "+10%";
481 "Mod+Right".action = set-column-width "+10%";
482
483 "Mod+Shift+Z" = {
484 action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors";
485 allow-when-locked = true;
486 };
487 "Mod+Shift+L".action = spawn loginctl "lock-session";
488 "Mod+Shift+E".action = quit;
489 "Mod+Shift+Minus" = {
490 action = spawn systemctl "suspend";
491 allow-when-locked = true;
492 };
493 "Mod+Shift+Control+Minus" = {
494 action = spawn systemctl "hibernate";
495 allow-when-locked = true;
496 };
497
498 "XF86MonBrightnessUp" = {
499 action = spawn lightctl "-d" "-e4" "-n1" "up";
500 allow-when-locked = true;
501 };
502 "XF86MonBrightnessDown" = {
503 action = spawn lightctl "-d" "-e4" "-n1" "down";
504 allow-when-locked = true;
505 };
506 "XF86AudioRaiseVolume" = {
507 action = spawn volumectl "-d" "-u" "up";
508 allow-when-locked = true;
509 };
510 "XF86AudioLowerVolume" = {
511 action = spawn volumectl "-d" "-u" "down";
512 allow-when-locked = true;
513 };
514 "XF86AudioMute" = {
515 action = spawn volumectl "-d" "toggle-mute";
516 allow-when-locked = true;
517 };
518 "XF86AudioMicMute" = {
519 action = spawn volumectl "-d" "-m" "toggle-mute";
520 allow-when-locked = true;
521 };
522
523 "Mod+Semicolon".action = spawn makoctl "dismiss" "--group";
524 "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all";
525 "Mod+Period".action = spawn makoctl "menu" (lib.getExe config.programs.fuzzel.package) "--dmenu";
526 "Mod+Comma".action = spawn makoctl "restore";
527
528 "Mod+Control+A".action = focus-or-spawn-action-app_id "com.saivert.pwvucontrol" "pwctl" "pwvucontrol";
529 "Mod+Control+P".action = focus-or-spawn-action-app_id "org.keepassxc.KeePassXC" "kpxc" "keepassxc";
530 "Mod+Control+B".action = focus-or-spawn-action-app_id ".blueman-manager-wrapped" "bmgr" "blueman-manager";
531 "Mod+Control+Return".action = focus-or-spawn-action-app_id "kitty-scratch" "term" "kitty" "--app-id" "kitty-scratch";
532 "Mod+Control+E".action = focus-or-spawn-action "select(.app_id == \"emacs\" and .title == \"scratch\")" "edit" "emacsclient" "-c" "--frame-parameters=(quote (name . \"scratch\"))";
533 };
534 };
535 };
536}
diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix
deleted file mode 100644
index 8abf14d8..00000000
--- a/accounts/gkleen@sif/niri/mako.nix
+++ /dev/null
@@ -1,50 +0,0 @@
1{ config, lib, ... }:
2{
3 config = {
4 services.mako = {
5 enable = true;
6 font = "Fira Sans 10";
7 format = "<i>%s</i>\\n%b";
8 margin = "2";
9 maxVisible = -1;
10 backgroundColor = "#000000dd";
11 progressColor = "source #223544ff";
12 width = 384;
13 extraConfig = ''
14 outer-margin=1
15 max-history=100
16
17 [grouped]
18 format=<b>(%g)</b> <i>%s</i>\n%b
19
20 [urgency=low]
21 text-color=#999999ff
22
23 [urgency=critical]
24 background-color=#900000dd
25
26 [app-name=Element]
27 group-by=summary
28
29 [mode=silent]
30 invisible=1
31 '';
32 };
33 systemd.user.services.mako = {
34 Unit = {
35 Description = "Mako notification daemon";
36 PartOf = [ "graphical-session.target" ];
37 };
38 Install = {
39 WantedBy = [ "graphical-session.target" ];
40 };
41 Service = {
42 Type = "dbus";
43 BusName = "org.freedesktop.Notifications";
44 ExecStart = lib.getExe config.services.mako.package;
45 RestartSec = 5;
46 Restart = "always";
47 };
48 };
49 };
50}
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix
deleted file mode 100644
index 79c429f8..00000000
--- a/accounts/gkleen@sif/niri/waybar.nix
+++ /dev/null
@@ -1,338 +0,0 @@
1{ lib, pkgs, ... }:
2{
3 config = {
4 programs.waybar = {
5 enable = true;
6 systemd = {
7 enable = true;
8 target = "graphical-session.target";
9 };
10 settings = let
11 windowRewrites = {
12 "(.*) — Mozilla Firefox" = "$1";
13 "(.*) - Mozilla Thunderbird" = "$1";
14 "(.*) - mpv" = "$1";
15 };
16 iconSize = 11;
17 in [
18 {
19 layer = "top";
20 position = "top";
21 height = 14;
22 output = [ "eDP-1" "DP-2" "DP-3" ];
23 modules-left = [ "niri/workspaces" ];
24 modules-center = [ "niri/window" ];
25 modules-right = [ # "custom/worktime" "custom/worktime-today"
26 "custom/weather"
27 "custom/keymap"
28 "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "custom/mako" "clock" ];
29
30 "custom/mako" = {
31 format = "{}";
32 return-type = "json";
33 exec = pkgs.writers.writePython3 "mako-silent" { libraries = [ pkgs.python3Packages.dbus-next ]; } ''
34 from dbus_next.aio import MessageBus
35
36 import asyncio
37
38 import json
39
40
41 loop = asyncio.new_event_loop()
42 asyncio.set_event_loop(loop)
43
44
45 async def main():
46 bus = await MessageBus().connect()
47 # the introspection xml would normally be included in your project, but
48 # this is convenient for development
49 introspection = await bus.introspect('org.freedesktop.Notifications', '/fr/emersion/Mako') # noqa: E501
50
51 obj = bus.get_proxy_object('org.freedesktop.Notifications', '/fr/emersion/Mako', introspection) # noqa: E501
52 mako = obj.get_interface('fr.emersion.Mako')
53 properties = obj.get_interface('org.freedesktop.DBus.Properties')
54
55 async def print_mode():
56 modes = await mako.get_modes()
57 is_silent = "silent" in modes
58 icon = "&#xf009b;" if is_silent else "&#xf009a;"
59 text = f"<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>" # noqa: E501
60 if is_silent:
61 text = f"<span color=\"#ffffff\">{text}</span>"
62 print(json.dumps({'text': text}, separators=(',', ':')), flush=True) # noqa: E501
63
64 async def on_properties_changed(interface_name, changed_properties, invalidated_properties): # noqa: E501
65 if "Modes" not in invalidated_properties:
66 return
67
68 await print_mode()
69
70 properties.on_properties_changed(on_properties_changed)
71 await print_mode()
72
73 await loop.create_future()
74
75
76 loop.run_until_complete(main())
77 '';
78 on-click = "makoctl mode -t silent";
79 };
80 "custom/weather" = {
81 format = "{}";
82 tooltip = true;
83 interval = 3600;
84 exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"100%\\\">{ICON}</span> {FeelsLikeC}°\"";
85 return-type = "json";
86 };
87 "custom/keymap" = {
88 format = "{}";
89 tooltip = true;
90 return-type = "json";
91 exec = pkgs.writers.writePython3 "keymap" {} ''
92 import os
93 import socket
94 import json
95
96
97 def output(keymap):
98 short = keymap
99 if keymap == "English (programmer Dvorak)":
100 short = "dvp"
101 elif keymap == "English (US)":
102 short = "<span color=\"#ffffff\">us</span>"
103 print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501
104
105
106 keyboard_layouts = []
107
108 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
109 sock.connect(os.environ["NIRI_SOCKET"])
110 sock.send(b"\"EventStream\"\n")
111 for line in sock.makefile(buffering=1, encoding='utf-8'):
112 if line_json := json.loads(line):
113 if "KeyboardLayoutsChanged" in line_json:
114 keyboard_layouts = line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["names"] # noqa: E501
115 output(keyboard_layouts[line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["current_idx"]]) # noqa: E501
116 if "KeyboardLayoutSwitched" in line_json:
117 output(keyboard_layouts[line_json["KeyboardLayoutSwitched"]["idx"]]) # noqa: E501
118 '';
119 on-click = "niri msg action switch-layout next";
120 };
121 "custom/worktime" = {
122 interval = 60;
123 exec = lib.getExe pkgs.worktime;
124 tooltip = false;
125 };
126 "custom/worktime-today" = {
127 interval = 60;
128 exec = "${lib.getExe pkgs.worktime} today";
129 tooltip = false;
130 };
131 "niri/workspaces" = {
132 ignore = ["pwctl" "kpxc" "bmgr" "edit" "term"];
133 };
134 "niri/window" = {
135 separate-outputs = true;
136 icon = true;
137 icon-size = 14;
138 rewrite = windowRewrites;
139 };
140 clock = {
141 interval = 1;
142 # timezone = "Europe/Berlin";
143 format = "W{:%V-%u %F %H:%M:%S%Ez}";
144 tooltip-format = "<tt><small>{calendar}</small></tt>";
145 calendar = {
146 mode = "year";
147 mode-mon-col = 3;
148 weeks-pos = "left";
149 on-scroll = 1;
150 format = {
151 months = "<span color='#ffead3'><b>{}</b></span>";
152 days = "{}";
153 weeks = "<span color='#99ffdd'><b>{}</b></span>";
154 weekdays = "<span color='#ffcc66'><b>{}</b></span>";
155 today = "<span color='#ff6699'><b>{}</b></span>";
156 };
157 };
158 };
159 battery = {
160 format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>";
161 icon-size = iconSize - 2;
162 states = { warning = 30; critical = 15; };
163 format-icons = ["&#xf008e;" "&#xf007a;" "&#xf007b;" "&#xf007c;" "&#xf007d;" "&#xf007e;" "&#xf007f;" "&#xf0080;" "&#xf0081;" "&#xf0082;" "&#xf0079;" ];
164 format-charging = "&#xf0084;";
165 format-plugged = "&#xf06a5;";
166 tooltip-format = "{capacity}% {timeTo}";
167 interval = 20;
168 };
169 tray = {
170 icon-size = 16;
171 # show-passive-items = true;
172 spacing = 1;
173 };
174 privacy = {
175 icon-spacing = 7;
176 icon-size = iconSize;
177 modules = [
178 { type = "screenshare"; }
179 { type = "audio-in"; }
180 ];
181 };
182 idle_inhibitor = {
183 format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>";
184 icon-size = iconSize;
185 format-icons = { activated = "&#xf0208;"; deactivated = "&#xf0209;"; };
186 timeout = 120;
187 };
188 backlight = {
189 format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>";
190 icon-size = iconSize;
191 tooltip-format = "{percent}%";
192 format-icons = ["&#xf00da;" "&#xf00db;" "&#xf00dc;" "&#xf00dd;" "&#xf00de;" "&#xf00df;" "&#xf00e0;"];
193 on-scroll-up = "lightctl -d -e4 -n1 up";
194 on-scroll-down = "lightctl -d -e4 -n1 down";
195 };
196 wireplumber = {
197 format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>";
198 icon-size = iconSize;
199 tooltip-format = "{volume}% {node_name}";
200 format-icons = ["&#xf057f;" "&#xf0580;" "&#xf057e;"];
201 format-muted = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">&#xf075f;</span>";
202 # ignored-sinks = ["Easy Effects Sink"];
203 on-scroll-up = "volumectl -d -u up";
204 on-scroll-down = "volumectl -d -u down";
205 on-click = "volumectl -d toggle-mute";
206 };
207 }
208 {
209 layer = "top";
210 position = "top";
211 height = 14;
212 output = [ "!eDP-1" "!DP-2" "!DP-3" ];
213 modules-left = [ "niri/workspaces" ];
214 modules-center = [ "niri/window" ];
215 modules-right = [ "clock" ];
216
217 "niri/workspaces" = {
218 ignore = ["pwctl" "kpxc" "bmgr" "edit" "term"];
219 };
220 "niri/window" = {
221 separate-outputs = true;
222 icon = true;
223 icon-size = 14;
224 rewrite = windowRewrites;
225 };
226 clock = {
227 interval = 1;
228 # timezone = "Europe/Berlin";
229 format = "{:%H:%M}";
230 tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}";
231 };
232 }
233 ];
234 style = ''
235 @define-color white #ffffff;
236 @define-color grey #555555;
237 @define-color blue #1a8fff;
238 @define-color green #23fd00;
239 @define-color orange #f28a21;
240 @define-color red #f2201f;
241
242 * {
243 border: none;
244 font-family: "Fira Sans Nerd Font";
245 font-size: 10pt;
246 min-height: 0;
247 }
248
249 window#waybar {
250 background-color: rgba(0, 0, 0, 0.66);
251 color: @white;
252 }
253
254 .modules-left {
255 margin-left: 8px;
256 }
257 .modules-right {
258 margin-right: 8px;
259 }
260
261 .module {
262 margin: 0 5px;
263 }
264
265 #workspaces button {
266 color: @white;
267 padding: 2px 5px;
268 }
269 #workspaces button.empty {
270 color: @grey;
271 }
272 #workspaces button.active {
273 color: @green;
274 }
275 #workspaces button.urgent {
276 color: @red;
277 }
278
279 #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today {
280 color: @grey;
281 margin: 0 5px;
282 }
283 #custom-weather, #custom-worktime-today {
284 margin-right: 3px;
285 }
286 #custom-keymap, #custom-weather {
287 margin-left: 3px;
288 }
289
290 #tray {
291 margin: 0;
292 }
293 #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako {
294 color: @grey;
295 margin: 0 5px 0 2px;
296 }
297 #idle_inhibitor {
298 margin-right: 4px;
299 margin-left: 6px;
300 }
301 #custom-mako {
302 margin-right: 2px;
303 margin-left: 3px;
304 }
305 #battery {
306 margin-right: 3px;
307 }
308 #battery.discharging {
309 color: @white;
310 }
311 #battery.warning {
312 color: @orange;
313 }
314 #battery.critical {
315 color: @red;
316 }
317 #battery.charging {
318 color: @white;
319 }
320 #idle_inhibitor.activated {
321 color: @white;
322 }
323
324 #idle_inhibitor {
325 padding-top: 1px;
326 }
327
328 #privacy {
329 color: @red;
330 margin: -1px 2px 0px 5px;
331 }
332 #clock {
333 /* margin-right: 5px; */
334 }
335 '';
336 };
337 };
338}