summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif')
-rw-r--r--accounts/gkleen@sif/niri/default.nix66
-rw-r--r--accounts/gkleen@sif/niri/waybar.nix34
2 files changed, 74 insertions, 26 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
index aa109616..57bc578c 100644
--- a/accounts/gkleen@sif/niri/default.nix
+++ b/accounts/gkleen@sif/niri/default.nix
@@ -96,6 +96,28 @@ let
96 ''; 96 '';
97 }; 97 };
98 with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); 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);
99in { 121in {
100 imports = [ 122 imports = [
101 ./waybar.nix 123 ./waybar.nix
@@ -152,7 +174,7 @@ in {
152 }; 174 };
153 175
154 outputs = { 176 outputs = {
155 "Samsung Display Corp. 0x4141 Unknown" = { 177 "eDP-1" = {
156 scale = 1.5; 178 scale = 1.5;
157 position = { x = 0; y = 0; }; 179 position = { x = 0; y = 0; };
158 }; 180 };
@@ -177,13 +199,13 @@ in {
177 active.gradient = { 199 active.gradient = {
178 from = "hsla(195 100% 60% 0.9)"; 200 from = "hsla(195 100% 60% 0.9)";
179 to = "hsla(155 100% 50% 0.9)"; 201 to = "hsla(155 100% 50% 0.9)";
180 angle = 45; 202 angle = 29;
181 relative-to = "workspace-view"; 203 relative-to = "workspace-view";
182 }; 204 };
183 inactive.gradient = { 205 inactive.gradient = {
184 from = "hsla(0 0% 42% 0.66)"; 206 from = "hsla(0 0% 42% 0.66)";
185 to = "hsla(0 0% 35% 0.66)"; 207 to = "hsla(0 0% 35% 0.66)";
186 angle = 45; 208 angle = 29;
187 relative-to = "workspace-view"; 209 relative-to = "workspace-view";
188 }; 210 };
189 }; 211 };
@@ -209,11 +231,11 @@ in {
209 cursor.hide-when-typing = true; 231 cursor.hide-when-typing = true;
210 232
211 workspaces = { 233 workspaces = {
212 "001".name = "pwctl"; 234 "001" = { name = "pwctl"; open-on-output = "eDP-1"; };
213 "002".name = "kpxc"; 235 "002" = { name = "kpxc"; open-on-output = "eDP-1"; };
214 "003".name = "bmgr"; 236 "003" = { name = "bmgr"; open-on-output = "eDP-1"; };
215 "004".name = "term"; 237 "004" = { name = "term"; open-on-output = "eDP-1"; };
216 "005".name = "edit"; 238 "005" = { name = "edit"; open-on-output = "eDP-1"; };
217 "101".name = "comm"; 239 "101".name = "comm";
218 "102".name = "web"; 240 "102".name = "web";
219 "104".name = "read"; 241 "104".name = "read";
@@ -329,8 +351,10 @@ in {
329 fi 351 fi
330 [[ -n "$QALC_RES" ]] || exit 1 352 [[ -n "$QALC_RES" ]] || exit 1
331 EXISTING=false 353 EXISTING=false
354 set +e
332 grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch 355 grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch
333 [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true 356 [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true
357 set -e
334 if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then 358 if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then
335 RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10) 359 RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10)
336 cat >"$RES_FILE" <<<"$QALC_RES" 360 cat >"$RES_FILE" <<<"$QALC_RES"
@@ -349,6 +373,26 @@ in {
349 wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste 373 wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste
350 ''; 374 '';
351 })); 375 }));
376 "Print".action = spawn (lib.getExe (pkgs.writeShellApplication {
377 name = "screenshot";
378 runtimeInputs = with pkgs; [ grim slurp wl-clipboard-rs coreutils ];
379 text = ''
380 grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" - \
381 | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \
382 | wl-copy --type image/png
383 '';
384 }));
385 "Shift+Print".action = spawn (lib.getExe (pkgs.writeShellApplication {
386 name = "screenshot";
387 runtimeInputs = with pkgs; [ grim niri gojq wl-clipboard-rs coreutils ];
388 text = ''
389 grim -o "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" - \
390 | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \
391 | wl-copy --type image/png
392 '';
393 }));
394 "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}";
395 "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}";
352 396
353 "Mod+H".action = focus-column-left; 397 "Mod+H".action = focus-column-left;
354 "Mod+T".action = focus-window-down; 398 "Mod+T".action = focus-window-down;
@@ -406,8 +450,8 @@ in {
406 "Mod+Shift+F".action = maximize-column; 450 "Mod+Shift+F".action = maximize-column;
407 "Mod+Shift+Ctrl+F".action = fullscreen-window; 451 "Mod+Shift+Ctrl+F".action = fullscreen-window;
408 452
409 "Mod+B".action = switch-focus-between-floating-and-tiling; 453 "Mod+V".action = switch-focus-between-floating-and-tiling;
410 "Mod+Shift+B".action = toggle-window-floating; 454 "Mod+Shift+V".action = toggle-window-floating;
411 455
412 "Mod+Left".action = set-column-width "-10%"; 456 "Mod+Left".action = set-column-width "-10%";
413 "Mod+Down".action = set-window-height "-10%"; 457 "Mod+Down".action = set-window-height "-10%";
@@ -422,9 +466,11 @@ in {
422 "Mod+Shift+E".action = quit; 466 "Mod+Shift+E".action = quit;
423 "Mod+Shift+Minus" = { 467 "Mod+Shift+Minus" = {
424 action = spawn systemctl "suspend"; 468 action = spawn systemctl "suspend";
469 allow-when-locked = true;
425 }; 470 };
426 "Mod+Shift+Control+Minus" = { 471 "Mod+Shift+Control+Minus" = {
427 action = spawn systemctl "hibernate"; 472 action = spawn systemctl "hibernate";
473 allow-when-locked = true;
428 }; 474 };
429 475
430 "XF86MonBrightnessUp" = { 476 "XF86MonBrightnessUp" = {
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix
index 2d00c6d8..ff48ba83 100644
--- a/accounts/gkleen@sif/niri/waybar.nix
+++ b/accounts/gkleen@sif/niri/waybar.nix
@@ -24,14 +24,14 @@
24 modules-center = [ "niri/window" ]; 24 modules-center = [ "niri/window" ];
25 modules-right = [ # "custom/worktime" "custom/worktime-today" 25 modules-right = [ # "custom/worktime" "custom/worktime-today"
26 "custom/weather" 26 "custom/weather"
27 # "custom/keymap" 27 "custom/keymap"
28 "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ]; 28 "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ];
29 29
30 "custom/weather" = { 30 "custom/weather" = {
31 format = "{}"; 31 format = "{}";
32 tooltip = true; 32 tooltip = true;
33 interval = 3600; 33 interval = 3600;
34 exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"120%\\\">{ICON}</span> {FeelsLikeC}°\""; 34 exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"100%\\\">{ICON}</span> {FeelsLikeC}°\"";
35 return-type = "json"; 35 return-type = "json";
36 }; 36 };
37 "custom/keymap" = { 37 "custom/keymap" = {
@@ -41,8 +41,6 @@
41 exec = pkgs.writers.writePython3 "keymap" {} '' 41 exec = pkgs.writers.writePython3 "keymap" {} ''
42 import os 42 import os
43 import socket 43 import socket
44 import re
45 import subprocess
46 import json 44 import json
47 45
48 46
@@ -55,20 +53,20 @@
55 print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 53 print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501
56 54
57 55
58 r = subprocess.run(["hyprctl", "devices", "-j"], check=True, stdout=subprocess.PIPE, text=True) # noqa: E501 56 keyboard_layouts = []
59 for keyboard in json.loads(r.stdout)['keyboards']:
60 if keyboard['name'] != "at-translated-set-2-keyboard":
61 continue
62 output(keyboard['active_keymap'])
63 57
64 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 58 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
65 sock.connect(os.environ["XDG_RUNTIME_DIR"] + "/hypr/" + os.environ["HYPRLAND_INSTANCE_SIGNATURE"] + "/.socket2.sock") # noqa: E501 59 sock.connect(os.environ["NIRI_SOCKET"])
66 expected = re.compile(r'^activelayout>>at-translated-set-2-keyboard,(?P<keymap>.+)$') # noqa: E501 60 sock.send(b"\"EventStream\"\n")
67 for line in sock.makefile(buffering=1, encoding='utf-8'): 61 for line in sock.makefile(buffering=1, encoding='utf-8'):
68 if match := expected.match(line): 62 if line_json := json.loads(line):
69 output(match.group("keymap")) 63 if "KeyboardLayoutsChanged" in line_json:
64 keyboard_layouts = line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["names"] # noqa: E501
65 output(keyboard_layouts[line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["current_idx"]]) # noqa: E501
66 if "KeyboardLayoutSwitched" in line_json:
67 output(keyboard_layouts[line_json["KeyboardLayoutSwitched"]["idx"]]) # noqa: E501
70 ''; 68 '';
71 on-click = "hyprctl switchxkblayout at-translated-set-2-keyboard next"; 69 on-click = "niri msg action switch-layout next";
72 }; 70 };
73 "custom/worktime" = { 71 "custom/worktime" = {
74 interval = 60; 72 interval = 60;
@@ -80,7 +78,9 @@
80 exec = "${lib.getExe pkgs.worktime} today"; 78 exec = "${lib.getExe pkgs.worktime} today";
81 tooltip = false; 79 tooltip = false;
82 }; 80 };
83 "niri/workspaces" = {}; 81 "niri/workspaces" = {
82 ignore = ["pwctl" "kpxc" "bmgr" "edit" "term"];
83 };
84 "niri/window" = { 84 "niri/window" = {
85 separate-outputs = true; 85 separate-outputs = true;
86 icon = true; 86 icon = true;
@@ -164,7 +164,9 @@
164 modules-center = [ "niri/window" ]; 164 modules-center = [ "niri/window" ];
165 modules-right = [ "clock" ]; 165 modules-right = [ "clock" ];
166 166
167 "niri/workspaces" = {}; 167 "niri/workspaces" = {
168 ignore = ["pwctl" "kpxc" "bmgr" "edit" "term"];
169 };
168 "niri/window" = { 170 "niri/window" = {
169 separate-outputs = true; 171 separate-outputs = true;
170 icon = true; 172 icon = true;