diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-01-16 10:02:16 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-01-16 10:02:16 +0100 |
commit | 5e770b536c71c1a136c7db391200b5563d8516ec (patch) | |
tree | a943bed9715f96f46da0eb3acf4d3926ea1a5832 /accounts/gkleen@sif/niri/default.nix | |
parent | bf5ffe04635753a796fd9f3d39392a15e5542ff2 (diff) | |
download | nixos-5e770b536c71c1a136c7db391200b5563d8516ec.tar nixos-5e770b536c71c1a136c7db391200b5563d8516ec.tar.gz nixos-5e770b536c71c1a136c7db391200b5563d8516ec.tar.bz2 nixos-5e770b536c71c1a136c7db391200b5563d8516ec.tar.xz nixos-5e770b536c71c1a136c7db391200b5563d8516ec.zip |
...
Diffstat (limited to 'accounts/gkleen@sif/niri/default.nix')
-rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index afedd6e3..36811d21 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); | ||
99 | in { | 121 | in { |
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 | }; |
@@ -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%"; |