diff options
Diffstat (limited to 'accounts/gkleen@sif/niri')
-rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 1222 | ||||
-rw-r--r-- | accounts/gkleen@sif/niri/mako.nix | 49 | ||||
-rw-r--r-- | accounts/gkleen@sif/niri/swayosd.nix | 7 | ||||
-rw-r--r-- | accounts/gkleen@sif/niri/waybar.nix | 31 |
4 files changed, 792 insertions, 517 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 7e187c84..35a3d799 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix | |||
@@ -1,6 +1,11 @@ | |||
1 | { config, hostConfig, pkgs, lib, ... }: | 1 | { config, hostConfig, pkgs, lib, flakeInputs, ... }: |
2 | let | 2 | let |
3 | niri = config.programs.niri.package; | 3 | cfg = config.programs.niri; |
4 | |||
5 | kdl = flakeInputs.niri-flake.lib.kdl; | ||
6 | sleaf = name: arg: kdl.node name [arg] []; | ||
7 | |||
8 | niri = cfg.package; | ||
4 | terminal = lib.getExe config.programs.kitty.package; | 9 | terminal = lib.getExe config.programs.kitty.package; |
5 | makoctl = lib.getExe' config.services.mako.package "makoctl"; | 10 | makoctl = lib.getExe' config.services.mako.package "makoctl"; |
6 | loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; | 11 | loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; |
@@ -31,7 +36,11 @@ let | |||
31 | if jq -e '.is_focused' <<<"$window_json" >/dev/null; then | 36 | if jq -e '.is_focused' <<<"$window_json" >/dev/null; then |
32 | niri msg action focus-workspace-previous | 37 | niri msg action focus-workspace-previous |
33 | else | 38 | else |
34 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" | 39 | if [[ $(jq -r --arg workspace_name "$workspace_name" 'map(select(.name == $workspace_name)) | .[0].is_focused' <<<"$workspaces_json") != "true" ]] && [[ $(jq -r --arg workspace_name "$workspace_name" 'map(select(.name == $workspace_name)) | .[0].id' <<<"$workspaces_json") = $(jq -r '.workspace_id' <<<"$window_json") ]]; then |
40 | niri msg action focus-workspace "$workspace_name" | ||
41 | else | ||
42 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" | ||
43 | fi | ||
35 | fi | 44 | fi |
36 | exit 0 | 45 | exit 0 |
37 | fi | 46 | fi |
@@ -41,7 +50,6 @@ let | |||
41 | ''; | 50 | ''; |
42 | }; | 51 | }; |
43 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); | 52 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); |
44 | focus-or-spawn-action-app_id = app_id: focus-or-spawn-action ''select(.app_id == "${app_id}")''; | ||
45 | 53 | ||
46 | with_adjacent_workspace = pkgs.writeShellApplication { | 54 | with_adjacent_workspace = pkgs.writeShellApplication { |
47 | name = "with-adjacent-workspace"; | 55 | name = "with-adjacent-workspace"; |
@@ -78,9 +86,9 @@ let | |||
78 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | 86 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" |
79 | ''; | 87 | ''; |
80 | }; | 88 | }; |
81 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^pwctl|eff|kpxc|bmgr|edit|term$"; | 89 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^${lib.concatMapStringsSep "|" ({ name, ...}: name) cfg.scratchspaces}$"; |
82 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | 90 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; |
83 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | 91 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; |
84 | 92 | ||
85 | with_unnamed_workspace = pkgs.writeShellApplication { | 93 | with_unnamed_workspace = pkgs.writeShellApplication { |
86 | name = "with-unnamed-workspace"; | 94 | name = "with-unnamed-workspace"; |
@@ -101,6 +109,21 @@ let | |||
101 | }; | 109 | }; |
102 | with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); | 110 | with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); |
103 | 111 | ||
112 | with_empty_unnamed_workspace = pkgs.writeShellApplication { | ||
113 | name = "with-empty-unnamed-workspace"; | ||
114 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
115 | text = '' | ||
116 | action="$1" | ||
117 | shift | ||
118 | |||
119 | workspaces_json="$(niri msg -j workspaces)" | ||
120 | active_output="$(jq '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
121 | target_workspace_id="$(jq --argjson active_output "$active_output" 'map(select(.active_window_id == null and .name == null and .output == $active_output)) | sort_by(.idx) | .[0].id' <<<"$workspaces_json")" | ||
122 | jq --argjson workspace_id "$target_workspace_id" -nc "$action" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
123 | ''; | ||
124 | }; | ||
125 | with-empty-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_empty_unnamed_workspace); | ||
126 | |||
104 | with_select_window = pkgs.writeShellApplication { | 127 | with_select_window = pkgs.writeShellApplication { |
105 | name = "with-select-window"; | 128 | name = "with-select-window"; |
106 | runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; | 129 | runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; |
@@ -112,7 +135,7 @@ let | |||
112 | 135 | ||
113 | windows_json="$(niri msg -j windows)" | 136 | windows_json="$(niri msg -j windows)" |
114 | active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" | 137 | active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" |
115 | 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)" | 138 | window_ix="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\u0000icon\u001f\(.app_id)"' <<<"$windows_json" | fuzzel --width=60 --log-level=warning --dmenu --index)" |
116 | # shellcheck disable=SC2016 | 139 | # shellcheck disable=SC2016 |
117 | window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" | 140 | window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" |
118 | 141 | ||
@@ -122,6 +145,25 @@ let | |||
122 | ''; | 145 | ''; |
123 | }; | 146 | }; |
124 | with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); | 147 | with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); |
148 | |||
149 | with_predicate_window = pred: pkgs.writeShellApplication { | ||
150 | name = "with-predicate-window"; | ||
151 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
152 | text = '' | ||
153 | action="$1" | ||
154 | shift | ||
155 | |||
156 | windows_json="$(niri msg -j windows)" | ||
157 | window_json="$(gojq -rc 'map(select(${pred})) | .[0]' <<<"$windows_json")" | ||
158 | |||
159 | [[ -z "$window_json" || $window_json = "null" ]] && exit 1 | ||
160 | |||
161 | jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" | ||
162 | ''; | ||
163 | }; | ||
164 | |||
165 | with-urgent-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_urgent")); | ||
166 | with-focused-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_focused")); | ||
125 | in { | 167 | in { |
126 | imports = [ | 168 | imports = [ |
127 | ./waybar.nix | 169 | ./waybar.nix |
@@ -129,6 +171,65 @@ in { | |||
129 | ./swayosd.nix | 171 | ./swayosd.nix |
130 | ]; | 172 | ]; |
131 | 173 | ||
174 | options = { | ||
175 | programs.niri.scratchspaces = lib.mkOption { | ||
176 | type = lib.types.listOf (lib.types.submodule ({ config, ... }: { | ||
177 | options = { | ||
178 | name = lib.mkOption { | ||
179 | type = lib.types.str; | ||
180 | }; | ||
181 | match = lib.mkOption { | ||
182 | type = lib.types.listOf (lib.types.attrsOf kdl.types.kdl-args); | ||
183 | default = []; | ||
184 | }; | ||
185 | exclude = lib.mkOption { | ||
186 | type = lib.types.listOf (lib.types.attrsOf kdl.types.kdl-args); | ||
187 | default = []; | ||
188 | }; | ||
189 | windowRuleExtra = lib.mkOption { | ||
190 | type = kdl.types.kdl-nodes; | ||
191 | default = []; | ||
192 | }; | ||
193 | key = lib.mkOption { | ||
194 | type = lib.types.nullOr lib.types.str; | ||
195 | default = null; | ||
196 | }; | ||
197 | moveKey = lib.mkOption { | ||
198 | type = lib.types.nullOr lib.types.str; | ||
199 | default = let | ||
200 | keys = lib.splitString "+" config.key; | ||
201 | defMoveKey = lib.concatStringsSep "+" (lib.flatten [ | ||
202 | (lib.take (lib.length keys - 1) keys) | ||
203 | ["Shift"] | ||
204 | (lib.takeEnd 1 keys) | ||
205 | ]); | ||
206 | in if config.key == null then null else defMoveKey; | ||
207 | }; | ||
208 | spawn = lib.mkOption { | ||
209 | type = lib.types.nullOr (lib.types.listOf lib.types.str); | ||
210 | default = null; | ||
211 | }; | ||
212 | app-id = lib.mkOption { | ||
213 | type = lib.types.nullOr lib.types.str; | ||
214 | default = null; | ||
215 | }; | ||
216 | selector = lib.mkOption { | ||
217 | type = lib.types.nullOr lib.types.str; | ||
218 | default = null; | ||
219 | }; | ||
220 | }; | ||
221 | |||
222 | config = lib.mkMerge [ | ||
223 | (lib.mkIf (config.app-id != null) { | ||
224 | match = lib.mkDefault [ { app-id = "^${lib.escapeRegex config.app-id}$"; } ]; | ||
225 | selector = lib.mkDefault "select(.app_id == \"${config.app-id}\")"; | ||
226 | }) | ||
227 | ]; | ||
228 | })); | ||
229 | default = []; | ||
230 | }; | ||
231 | }; | ||
232 | |||
132 | config = { | 233 | config = { |
133 | systemd.user.services.xwayland-satellite = { | 234 | systemd.user.services.xwayland-satellite = { |
134 | Unit = { | 235 | Unit = { |
@@ -155,7 +256,7 @@ in { | |||
155 | { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; } | 256 | { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; } |
156 | ]; | 257 | ]; |
157 | timeouts = [ | 258 | timeouts = [ |
158 | { timeout = 300; | 259 | { timeout = 540; |
159 | command = "${lib.getExe niri} msg action power-off-monitors"; | 260 | command = "${lib.getExe niri} msg action power-off-monitors"; |
160 | } | 261 | } |
161 | ]; | 262 | ]; |
@@ -178,11 +279,11 @@ in { | |||
178 | Service = { | 279 | Service = { |
179 | Type = "simple"; | 280 | Type = "simple"; |
180 | Sockets = [ "niri-workspace-history.socket" ]; | 281 | Sockets = [ "niri-workspace-history.socket" ]; |
181 | ExecStart = pkgs.writers.writePython3 "niri-workspace-history" {} '' | 282 | ExecStart = pkgs.writers.writePython3 "niri-workspace-history" { flakeIgnore = ["E501"]; } '' |
182 | import os | 283 | import os |
183 | import socket | 284 | import socket |
184 | import json | 285 | import json |
185 | import sys | 286 | # import sys |
186 | from collections import defaultdict | 287 | from collections import defaultdict |
187 | from threading import Thread, Lock | 288 | from threading import Thread, Lock |
188 | from socketserver import StreamRequestHandler, ThreadingTCPServer | 289 | from socketserver import StreamRequestHandler, ThreadingTCPServer |
@@ -206,11 +307,9 @@ in { | |||
206 | workspaces = list() | 307 | workspaces = list() |
207 | 308 | ||
208 | def focus_workspace(output, workspace): | 309 | def focus_workspace(output, workspace): |
209 | global workspace_history, history_lock | ||
210 | |||
211 | with history_lock: | 310 | with history_lock: |
212 | workspace_history[output] = [workspace] + [ws for ws in workspace_history[output] if ws != workspace] # noqa: E501 | 311 | workspace_history[output] = [workspace] + [ws for ws in workspace_history[output] if ws != workspace] |
213 | print(json.dumps(workspace_history), file=sys.stderr) | 312 | # print(json.dumps(workspace_history), file=sys.stderr) |
214 | 313 | ||
215 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | 314 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
216 | sock.connect(os.environ["NIRI_SOCKET"]) | 315 | sock.connect(os.environ["NIRI_SOCKET"]) |
@@ -232,16 +331,14 @@ in { | |||
232 | 331 | ||
233 | class RequestHandler(StreamRequestHandler): | 332 | class RequestHandler(StreamRequestHandler): |
234 | def handle(self): | 333 | def handle(self): |
235 | global workspace_history, history_lock | 334 | with detaching(TextIOWrapper(self.wfile, encoding='utf-8', write_through=True)) as out: |
236 | |||
237 | with detaching(TextIOWrapper(self.wfile, encoding='utf-8', write_through=True)) as out: # noqa: E501 | ||
238 | with history_lock: | 335 | with history_lock: |
239 | json.dump(workspace_history, out) | 336 | json.dump(workspace_history, out) |
240 | 337 | ||
241 | 338 | ||
242 | class Server(ThreadingTCPServer): | 339 | class Server(ThreadingTCPServer): |
243 | def __init__(self): | 340 | def __init__(self): |
244 | ThreadingTCPServer.__init__(self, ("", 8000), RequestHandler, bind_and_activate=False) # noqa: E501 | 341 | ThreadingTCPServer.__init__(self, ("", 8000), RequestHandler, bind_and_activate=False) |
245 | self.socket = socket.fromfd(3, self.address_family, self.socket_type) | 342 | self.socket = socket.fromfd(3, self.address_family, self.socket_type) |
246 | 343 | ||
247 | 344 | ||
@@ -267,477 +364,646 @@ in { | |||
267 | ''; | 364 | ''; |
268 | }; | 365 | }; |
269 | }; | 366 | }; |
270 | 367 | systemd.user.services.niri-workspace-sort = { | |
271 | programs.niri.settings = { | 368 | Unit = { |
272 | prefer-no-csd = true; | 369 | BindsTo = [ "niri.service" ]; |
273 | screenshot-path = "${config.home.homeDirectory}/screenshots"; | 370 | After = [ "niri.service" ]; |
274 | |||
275 | hotkey-overlay.skip-at-startup = true; | ||
276 | |||
277 | input = { | ||
278 | keyboard = { | ||
279 | repeat-delay = 300; | ||
280 | repeat-rate = 50; | ||
281 | |||
282 | xkb = { | ||
283 | layout = "us,us"; | ||
284 | variant = "dvp,"; | ||
285 | options = "compose:caps,grp:win_space_toggle"; | ||
286 | }; | ||
287 | }; | ||
288 | |||
289 | workspace-auto-back-and-forth = true; | ||
290 | # focus-follows-mouse.enable = true; | ||
291 | warp-mouse-to-focus = true; | ||
292 | }; | ||
293 | |||
294 | outputs = { | ||
295 | "eDP-1" = { | ||
296 | scale = 1.5; | ||
297 | position = { x = 0; y = 0; }; | ||
298 | }; | ||
299 | "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" = { | ||
300 | scale = 1.5; | ||
301 | position = { x = 2560; y = 0; }; | ||
302 | }; | ||
303 | "HP Inc. HP 727pu CN4417143K" = { | ||
304 | mode = { width = 2560; height = 1440; refresh = 119.998; }; | ||
305 | scale = 1; | ||
306 | position = { x = 2560; y = 0; }; | ||
307 | variable-refresh-rate = "on-demand"; | ||
308 | }; | ||
309 | }; | ||
310 | |||
311 | environment = { | ||
312 | NIXOS_OZONE_WL = "1"; | ||
313 | QT_QPA_PLATFORM = "wayland"; | ||
314 | QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; | ||
315 | GDK_BACKEND = "wayland"; | ||
316 | SDL_VIDEODRIVER = "wayland"; | ||
317 | DISPLAY = ":0"; | ||
318 | }; | 371 | }; |
319 | 372 | Install = { | |
320 | debug.render-drm-device = "/dev/dri/by-path/pci-0000:00:02.0-render"; | 373 | WantedBy = [ "niri.service" ]; |
321 | |||
322 | animations = { | ||
323 | slowdown = 0.5; | ||
324 | workspace-switch = null; | ||
325 | }; | 374 | }; |
375 | Service = { | ||
376 | Type = "simple"; | ||
377 | ExecStart = pkgs.writers.writePython3 "niri-workspace-sort" { flakeIgnore = ["E501"]; } '' | ||
378 | import os | ||
379 | import sys | ||
380 | import socket | ||
381 | import json | ||
326 | 382 | ||
327 | layout = { | 383 | outputs = None |
328 | gaps = 8; | 384 | only = {'HDMI-A-1': {'bmr'}, 'eDP-1': {'vid'}} |
329 | struts = { left = 0; right = 0; top = 0; bottom = 0; }; | ||
330 | focus-ring = { | ||
331 | width = 2; | ||
332 | active.gradient = { | ||
333 | from = "hsla(195 100% 60% 0.75)"; | ||
334 | to = "hsla(155 100% 50% 0.75)"; | ||
335 | angle = 29; | ||
336 | relative-to = "workspace-view"; | ||
337 | }; | ||
338 | inactive.gradient = { | ||
339 | from = "hsla(0 0% 42% 0.66)"; | ||
340 | to = "hsla(0 0% 35% 0.66)"; | ||
341 | angle = 29; | ||
342 | relative-to = "workspace-view"; | ||
343 | }; | ||
344 | }; | ||
345 | 385 | ||
346 | preset-column-widths = [ | ||
347 | { proportion = 1. / 4.; } | ||
348 | { proportion = 1. / 3.; } | ||
349 | { proportion = 1. / 2.; } | ||
350 | { proportion = 2. / 3.; } | ||
351 | { proportion = 3. / 4.; } | ||
352 | ]; | ||
353 | default-column-width.proportion = 1. / 2.; | ||
354 | preset-window-heights = [ | ||
355 | { proportion = 1. / 3.; } | ||
356 | { proportion = 1. / 2.; } | ||
357 | { proportion = 2. / 3.; } | ||
358 | { proportion = 1.; } | ||
359 | ]; | ||
360 | 386 | ||
361 | always-center-single-column = true; | 387 | class Niri(socket.socket): |
362 | }; | 388 | def __init__(self): |
389 | super().__init__(socket.AF_UNIX, socket.SOCK_STREAM) | ||
390 | super().connect(os.environ["NIRI_SOCKET"]) | ||
391 | self.fh = super().makefile(mode='rw', buffering=1, encoding='utf-8') | ||
363 | 392 | ||
364 | cursor.hide-when-typing = true; | 393 | def cmd(self, obj): |
394 | print(json.dumps(obj, separators=(',', ':')), flush=True, file=self.fh) | ||
365 | 395 | ||
366 | input = { | 396 | def event_stream(self): |
367 | touchpad.enable = false; | 397 | self.cmd("EventStream") |
368 | trackball = { | 398 | return self.fh |
369 | scroll-method = "on-button-down"; | ||
370 | scroll-button = 278; | ||
371 | }; | ||
372 | }; | ||
373 | 399 | ||
374 | workspaces = { | ||
375 | "001" = { name = "pwctl"; open-on-output = "eDP-1"; }; | ||
376 | "002" = { name = "kpxc"; open-on-output = "eDP-1"; }; | ||
377 | "003" = { name = "bmgr"; open-on-output = "eDP-1"; }; | ||
378 | "004" = { name = "term"; open-on-output = "eDP-1"; }; | ||
379 | "005" = { name = "edit"; open-on-output = "eDP-1"; }; | ||
380 | "006" = { name = "eff"; open-on-output = "eDP-1"; }; | ||
381 | "101".name = "comm"; | ||
382 | "102".name = "web"; | ||
383 | # "104".name = "read"; | ||
384 | # "105".name = "mon"; | ||
385 | "110".name = "vid"; | ||
386 | "120".name = "bmr"; | ||
387 | }; | ||
388 | 400 | ||
389 | window-rules = [ | 401 | with Niri() as niri, Niri().event_stream() as niri_stream: |
390 | { | 402 | for line in niri_stream: |
391 | matches = [ { is-floating = true; } ]; | 403 | workspaces = None |
392 | geometry-corner-radius = | 404 | if line_json := json.loads(line): |
393 | let | 405 | if "WorkspacesChanged" in line_json: |
394 | allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; }; | 406 | workspaces = line_json["WorkspacesChanged"]["workspaces"] |
395 | in allCorners 8.; | ||
396 | clip-to-geometry = true; | ||
397 | } | ||
398 | { | ||
399 | matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ]; | ||
400 | open-on-workspace = "pwctl"; | ||
401 | open-maximized = true; | ||
402 | } | ||
403 | { | ||
404 | matches = [ { app-id = "^com\.github\.wwmm\.easyeffects$"; } ]; | ||
405 | open-on-workspace = "eff"; | ||
406 | open-maximized = true; | ||
407 | } | ||
408 | { | ||
409 | matches = [ { app-id = "^\.blueman-manager-wrapped$"; } ]; | ||
410 | open-on-workspace = "bmgr"; | ||
411 | open-maximized = true; | ||
412 | } | ||
413 | { | ||
414 | matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; } ]; | ||
415 | block-out-from = "screencast"; | ||
416 | } | ||
417 | { | ||
418 | matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; } ]; | ||
419 | excludes = [ | ||
420 | { title = "^Unlock Database.*"; } | ||
421 | { title = "^Access Request.*"; } | ||
422 | { title = ".*Passkey credentials$"; } | ||
423 | ]; | ||
424 | open-on-workspace = "kpxc"; | ||
425 | open-maximized = true; | ||
426 | open-focused = false; | ||
427 | } | ||
428 | { | ||
429 | matches = [ | ||
430 | { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Unlock Database.*"; } | ||
431 | { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Access Request.*"; } | ||
432 | { app-id = "^org\.keepassxc\.KeePassXC$"; title = ".*Passkey credentials$"; } | ||
433 | ]; | ||
434 | open-focused = true; | ||
435 | open-floating = true; | ||
436 | } | ||
437 | { | ||
438 | matches = [ { app-id = "^kitty-scratch$"; } ]; | ||
439 | open-on-workspace = "term"; | ||
440 | open-maximized = true; | ||
441 | } | ||
442 | { | ||
443 | matches = [ { title = "^scratch$"; app-id = "^emacs$"; } ]; | ||
444 | open-on-workspace = "edit"; | ||
445 | open-maximized = true; | ||
446 | } | ||
447 | { | ||
448 | matches = [ | ||
449 | { app-id = "^emacs$"; } | ||
450 | { app-id = "^firefox$"; } | ||
451 | ]; | ||
452 | default-column-width.proportion = 2. / 3.; | ||
453 | } | ||
454 | { | ||
455 | matches = [ | ||
456 | { app-id = "^kitty$"; } | ||
457 | { app-id = "^kitty-play$"; } | ||
458 | ]; | ||
459 | default-column-width.proportion = 1. / 3.; | ||
460 | } | ||
461 | { | ||
462 | matches = [ | ||
463 | { app-id = "^thunderbird$"; } | ||
464 | { app-id = "^Element$"; } | ||
465 | { app-id = "^Rainbow$"; } | ||
466 | ]; | ||
467 | open-on-workspace = "comm"; | ||
468 | } | ||
469 | { | ||
470 | matches = [ { app-id = "^firefox$"; } ]; | ||
471 | open-on-workspace = "web"; | ||
472 | open-maximized = true; | ||
473 | variable-refresh-rate = true; | ||
474 | } | ||
475 | # { | ||
476 | # matches = [ | ||
477 | # { app-id = "^evince$"; } | ||
478 | # { app-id = "^imv$"; } | ||
479 | # { app-id = "^org\.pwmt\.zathura$"; } | ||
480 | # ]; | ||
481 | # open-on-workspace = "read"; | ||
482 | # } | ||
483 | { | ||
484 | matches = [ { app-id = "^mpv$"; } ]; | ||
485 | open-on-workspace = "vid"; | ||
486 | default-column-width.proportion = 1.; | ||
487 | variable-refresh-rate = true; | ||
488 | } | ||
489 | { | ||
490 | matches = [ { app-id = "^kitty-play$"; } ]; | ||
491 | open-on-workspace = "vid"; | ||
492 | open-focused = false; | ||
493 | } | ||
494 | # { | ||
495 | # matches = [ | ||
496 | # { app-id = "^qemu$"; } | ||
497 | # { app-id = "^virt-manager$"; } | ||
498 | # ]; | ||
499 | # open-on-workspace = "mon"; | ||
500 | # } | ||
501 | { | ||
502 | matches = [ { app-id = "^pdfpc$"; } ]; | ||
503 | default-column-width.proportion = 1.; | ||
504 | } | ||
505 | { | ||
506 | matches = [ { app-id = "^pdfpc$"; title = "^pdfpc - presentation"; } ]; | ||
507 | open-on-workspace = "bmr"; | ||
508 | open-fullscreen = true; | ||
509 | } | ||
510 | { | ||
511 | matches = [ | ||
512 | { app-id = "^Gimp-"; title = "^Quit GIMP$"; } | ||
513 | { app-id = "^org\.kde\.polkit-kde-authentication-agent-1$"; } | ||
514 | { app-id = "^xdg-desktop-portal-gtk$"; } | ||
515 | ]; | ||
516 | open-floating = true; | ||
517 | } | ||
518 | ]; | ||
519 | layer-rules = [ | ||
520 | { matches = [ | ||
521 | { namespace = "^notifications$"; } | ||
522 | { namespace = "^waybar$"; } | ||
523 | ]; | ||
524 | block-out-from = "screencast"; | ||
525 | } | ||
526 | ]; | ||
527 | |||
528 | binds = with config.lib.niri.actions; { | ||
529 | "Mod+Slash".action = show-hotkey-overlay; | ||
530 | |||
531 | "Mod+Return".action = spawn terminal; | ||
532 | "Mod+Q".action = close-window; | ||
533 | "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); | ||
534 | "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; | ||
535 | |||
536 | "Mod+Alt+E".action = spawn (lib.getExe' config.services.emacs.package "emacsclient") "-c"; | ||
537 | "Mod+Alt+Y".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
538 | name = "queue-yt-dlp"; | ||
539 | runtimeInputs = with pkgs; [ wl-clipboard-rs socat ]; | ||
540 | text = '' | ||
541 | socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' | ||
542 | ''; | ||
543 | })); | ||
544 | "Mod+Alt+L".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
545 | name = "queue-yt-dlp"; | ||
546 | runtimeInputs = with pkgs; [ wl-clipboard-rs config.programs.kitty.package ]; | ||
547 | text = '' | ||
548 | exec -- kitty --app-id kitty-play --directory "$HOME"/media mpv "$(wl-paste)" | ||
549 | ''; | ||
550 | })); | ||
551 | |||
552 | "Mod+U".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
553 | name = "qalc-fuzzel"; | ||
554 | runtimeInputs = with pkgs; [ wl-clipboard-rs libqalculate config.programs.fuzzel.package coreutils findutils libnotify gnugrep ]; | ||
555 | text = '' | ||
556 | RESULTS_DIR="$HOME/.cache/qalc-fuzzel" | ||
557 | prev() { | ||
558 | FOUND=false | ||
559 | while IFS= read -r line; do | ||
560 | [[ -n "$line" ]] || continue | ||
561 | FOUND=true | ||
562 | echo "$line" | ||
563 | 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) | ||
564 | $FOUND || echo | ||
565 | } | ||
566 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? | ||
567 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then | ||
568 | QALC_RES="$FUZZEL_RES" | ||
569 | QALC_RET=0 | ||
570 | else | ||
571 | QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) | ||
572 | QALC_RET=$? | ||
573 | fi | ||
574 | [[ -n "$QALC_RES" ]] || exit 1 | ||
575 | EXISTING=false | ||
576 | set +o pipefail | ||
577 | grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch | ||
578 | [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true | ||
579 | set -o pipefail | ||
580 | if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then | ||
581 | set +o pipefail | ||
582 | RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10) | ||
583 | set -o pipefail | ||
584 | cat >"$RES_FILE" <<<"$QALC_RES" | ||
585 | fi | ||
586 | [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" | ||
587 | [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" | ||
588 | notify-send "$QALC_RES" | ||
589 | ''; | ||
590 | })); | ||
591 | "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
592 | name = "emoji-fuzzel"; | ||
593 | runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ]; | ||
594 | text = '' | ||
595 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <"$HOME"/.local/share/emoji-data/list.txt) || exit $? | ||
596 | [[ -n "$FUZZEL_RES" ]] || exit 1 | ||
597 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste | ||
598 | ''; | ||
599 | })); | ||
600 | "Print".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
601 | name = "screenshot"; | ||
602 | runtimeInputs = with pkgs; [ grim slurp wl-clipboard-rs coreutils ]; | ||
603 | text = '' | ||
604 | grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" - \ | ||
605 | | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ | ||
606 | | wl-copy --type image/png | ||
607 | ''; | ||
608 | })); | ||
609 | "Shift+Print".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
610 | name = "screenshot"; | ||
611 | runtimeInputs = with pkgs; [ grim niri gojq wl-clipboard-rs coreutils ]; | ||
612 | text = '' | ||
613 | grim -o "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" - \ | ||
614 | | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ | ||
615 | | wl-copy --type image/png | ||
616 | ''; | ||
617 | })); | ||
618 | "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
619 | "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
620 | |||
621 | "Mod+H".action = focus-column-left; | ||
622 | "Mod+T".action = focus-window-down; | ||
623 | "Mod+N".action = focus-window-up; | ||
624 | "Mod+S".action = focus-column-right; | ||
625 | |||
626 | "Mod+Shift+H".action = move-column-left; | ||
627 | "Mod+Shift+T".action = move-window-down; | ||
628 | "Mod+Shift+N".action = move-window-up; | ||
629 | "Mod+Shift+S".action = move-column-right; | ||
630 | |||
631 | "Mod+Control+H".action = focus-monitor-left; | ||
632 | "Mod+Control+T".action = focus-monitor-down; | ||
633 | "Mod+Control+N".action = focus-monitor-up; | ||
634 | "Mod+Control+S".action = focus-monitor-right; | ||
635 | |||
636 | "Mod+Shift+Control+H".action = move-workspace-to-monitor-left; | ||
637 | "Mod+Shift+Control+T".action = move-workspace-to-monitor-down; | ||
638 | "Mod+Shift+Control+N".action = move-workspace-to-monitor-up; | ||
639 | "Mod+Shift+Control+S".action = move-workspace-to-monitor-right; | ||
640 | |||
641 | "Mod+G".action = focus-adjacent-workspace "down"; | ||
642 | "Mod+C".action = focus-adjacent-workspace "up"; | ||
643 | |||
644 | "Mod+Shift+G".action = move-column-to-adjacent-workspace "down"; | ||
645 | "Mod+Shift+C".action = move-column-to-adjacent-workspace "up"; | ||
646 | |||
647 | "Mod+Shift+Control+G".action = move-workspace-down; | ||
648 | "Mod+Shift+Control+C".action = move-workspace-up; | ||
649 | |||
650 | "Mod+ParenLeft".action = focus-workspace "comm"; | ||
651 | "Mod+Shift+ParenLeft".action = move-column-to-workspace "comm"; | ||
652 | |||
653 | "Mod+ParenRight".action = focus-workspace "web"; | ||
654 | "Mod+Shift+ParenRight".action = move-column-to-workspace "web"; | ||
655 | |||
656 | "Mod+BraceRight".action = focus-workspace "read"; | ||
657 | "Mod+Shift+BraceRight".action = move-column-to-workspace "read"; | ||
658 | |||
659 | "Mod+BraceLeft".action = focus-workspace "mon"; | ||
660 | "Mod+Shift+BraceLeft".action = move-column-to-workspace "mon"; | ||
661 | |||
662 | "Mod+Asterisk".action = focus-workspace "vid"; | ||
663 | "Mod+Shift+Asterisk".action = move-column-to-workspace "vid"; | ||
664 | |||
665 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
666 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | ||
667 | |||
668 | "Mod+M".action = consume-or-expel-window-left; | ||
669 | "Mod+W".action = consume-or-expel-window-right; | ||
670 | |||
671 | "Mod+R".action = switch-preset-column-width; | ||
672 | "Mod+Shift+R".action = switch-preset-window-height; | ||
673 | "Mod+F".action = center-column; | ||
674 | "Mod+Shift+F".action = maximize-column; | ||
675 | "Mod+Shift+Ctrl+F".action = fullscreen-window; | ||
676 | |||
677 | "Mod+V".action = switch-focus-between-floating-and-tiling; | ||
678 | "Mod+Shift+V".action = toggle-window-floating; | ||
679 | |||
680 | "Mod+Left".action = set-column-width "-10%"; | ||
681 | "Mod+Down".action = set-window-height "-10%"; | ||
682 | "Mod+Up".action = set-window-height "+10%"; | ||
683 | "Mod+Right".action = set-column-width "+10%"; | ||
684 | |||
685 | "Mod+Shift+Z" = { | ||
686 | action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; | ||
687 | allow-when-locked = true; | ||
688 | }; | ||
689 | "Mod+Shift+L".action = spawn loginctl "lock-session"; | ||
690 | "Mod+Shift+E".action = quit; | ||
691 | "Mod+Shift+Minus" = { | ||
692 | action = spawn systemctl "suspend"; | ||
693 | allow-when-locked = true; | ||
694 | }; | ||
695 | "Mod+Shift+Control+Minus" = { | ||
696 | action = spawn systemctl "hibernate"; | ||
697 | allow-when-locked = true; | ||
698 | }; | ||
699 | "Mod+Shift+P" = { | ||
700 | action = spawn (lib.getExe pkgs.playerctl) "-a" "pause"; | ||
701 | allow-when-locked = true; | ||
702 | }; | ||
703 | |||
704 | "XF86MonBrightnessUp" = { | ||
705 | action = spawn swayosd-client "--brightness" "raise"; | ||
706 | allow-when-locked = true; | ||
707 | }; | ||
708 | "XF86MonBrightnessDown" = { | ||
709 | action = spawn swayosd-client "--brightness" "lower"; | ||
710 | allow-when-locked = true; | ||
711 | }; | ||
712 | "XF86AudioRaiseVolume" = { | ||
713 | action = spawn swayosd-client "--output-volume" "raise"; | ||
714 | allow-when-locked = true; | ||
715 | }; | ||
716 | "XF86AudioLowerVolume" = { | ||
717 | action = spawn swayosd-client "--output-volume" "lower"; | ||
718 | allow-when-locked = true; | ||
719 | }; | ||
720 | "XF86AudioMute" = { | ||
721 | action = spawn swayosd-client "--output-volume" "mute-toggle"; | ||
722 | allow-when-locked = true; | ||
723 | }; | ||
724 | "XF86AudioMicMute" = { | ||
725 | action = spawn swayosd-client "--input-volume" "mute-toggle"; | ||
726 | allow-when-locked = true; | ||
727 | }; | ||
728 | 407 | ||
729 | "Mod+Semicolon".action = spawn makoctl "dismiss" "--group"; | 408 | if workspaces is None: |
730 | "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; | 409 | continue |
731 | "Mod+Period".action = spawn makoctl "menu" (lib.getExe config.programs.fuzzel.package) "--dmenu"; | 410 | |
732 | "Mod+Comma".action = spawn makoctl "restore"; | 411 | old_outputs = outputs |
733 | 412 | outputs = {ws["output"] for ws in workspaces} | |
734 | "Mod+Control+A".action = focus-or-spawn-action-app_id "com.saivert.pwvucontrol" "pwctl" "pwvucontrol"; | 413 | if old_outputs is None: |
735 | "Mod+Control+O".action = focus-or-spawn-action-app_id "com.github.wwmm.easyeffects" "eff" "easyeffects"; | 414 | print("Initial outputs: {}".format(outputs), file=sys.stderr) |
736 | "Mod+Control+P".action = focus-or-spawn-action-app_id "org.keepassxc.KeePassXC" "kpxc" "keepassxc"; | 415 | continue |
737 | "Mod+Control+B".action = focus-or-spawn-action-app_id ".blueman-manager-wrapped" "bmgr" "blueman-manager"; | 416 | |
738 | "Mod+Control+Return".action = focus-or-spawn-action-app_id "kitty-scratch" "term" "kitty" "--app-id" "kitty-scratch"; | 417 | new_outputs = outputs - old_outputs |
739 | "Mod+Control+E".action = focus-or-spawn-action "select(.app_id == \"emacs\" and .title == \"scratch\")" "edit" "emacsclient" "-c" "--frame-parameters=(quote (name . \"scratch\"))"; | 418 | if not new_outputs: |
419 | continue | ||
420 | print("New outputs: {}".format(new_outputs), file=sys.stderr) | ||
421 | |||
422 | relevant_workspaces = list(filter(lambda ws: (ws["name"] is not None) or (ws["active_window_id"] is not None), workspaces)) | ||
423 | target_output = next(iter(outputs - set(only.keys()))) | ||
424 | if not target_output: | ||
425 | continue | ||
426 | for ws in relevant_workspaces: | ||
427 | ws_ident = ws["name"] if ws["name"] is not None else (ws["output"], ws["idx"]) | ||
428 | if ws["output"] not in set(only.keys()): | ||
429 | continue | ||
430 | if ws_ident in only[ws["output"]]: | ||
431 | continue | ||
432 | |||
433 | print("{} -> {}".format(ws_ident, target_output), file=sys.stderr) | ||
434 | niri.cmd({"Action": {"MoveWorkspaceToMonitor": {"reference": {"Id": ws["id"]}, "output": target_output}}}) | ||
435 | ''; | ||
436 | Restart = "on-failure"; | ||
437 | RestartSec = 10; | ||
740 | }; | 438 | }; |
741 | }; | 439 | }; |
440 | |||
441 | programs.niri.scratchspaces = [ | ||
442 | { name = "pwctl"; | ||
443 | key = "Mod+Control+A"; | ||
444 | spawn = ["pwvucontrol"]; | ||
445 | app-id = "com.saivert.pwvucontrol"; | ||
446 | } | ||
447 | { name = "kpxc"; | ||
448 | exclude = [ | ||
449 | { title = "^Unlock Database.*"; } | ||
450 | { title = "^Access Request.*"; } | ||
451 | { title = ".*Passkey credentials$"; } | ||
452 | ]; | ||
453 | windowRuleExtra = with kdl; [ | ||
454 | (sleaf "open-focused" false) | ||
455 | ]; | ||
456 | key = "Mod+Control+P"; | ||
457 | app-id = "org.keepassxc.KeePassXC"; | ||
458 | spawn = [ "keepassxc" ]; | ||
459 | } | ||
460 | { name = "bmgr"; | ||
461 | key = "Mod+Control+B"; | ||
462 | app-id = ".blueman-manager-wrapped"; | ||
463 | spawn = [ "blueman-manager" ]; | ||
464 | } | ||
465 | { name = "term"; | ||
466 | key = "Mod+Control+Return"; | ||
467 | app-id = "kitty-scratch"; | ||
468 | spawn = [ "kitty" "--app-id" "kitty-scratch" ]; | ||
469 | } | ||
470 | { name = "edit"; | ||
471 | match = [ { title = "^scratch$"; app-id = "^emacs$"; } ]; | ||
472 | key = "Mod+Control+E"; | ||
473 | selector = "select(.app_id == \"emacs\" and .title == \"scratch\")"; | ||
474 | spawn = [ "emacsclient" "-c" "--frame-parameters=(quote (name . \"scratch\"))" ]; | ||
475 | } | ||
476 | { name = "eff"; | ||
477 | key = "Mod+Control+O"; | ||
478 | app-id = "com.github.wwmm.easyeffects"; | ||
479 | spawn = [ "easyeffects" ]; | ||
480 | } | ||
481 | { name = "time"; | ||
482 | key = "Mod+Control+K"; | ||
483 | app-id = "chrome-kimai.yggdrasil.li__-Default"; | ||
484 | spawn = [ (toString (pkgs.resholve.writeScript "kimai" { | ||
485 | interpreter = pkgs.runtimeShell; | ||
486 | inputs = [ pkgs.dex ]; | ||
487 | execer = [ "cannot:${lib.getExe pkgs.dex}" ]; | ||
488 | } '' | ||
489 | exec dex $HOME/.local/state/nix/profile/share/applications/kimai.desktop | ||
490 | '')) ]; | ||
491 | windowRuleExtra = with kdl; [ | ||
492 | (sleaf "block-out-from" "screencast") | ||
493 | ]; | ||
494 | } | ||
495 | ]; | ||
496 | programs.niri.config = | ||
497 | let | ||
498 | inherit (kdl) node plain leaf flag; | ||
499 | optional-node = cond: v: | ||
500 | if cond | ||
501 | then v | ||
502 | else null; | ||
503 | opt-props = lib.filterAttrs (lib.const (value: value != null)); | ||
504 | normalize-nodes = nodes: lib.remove null (lib.flatten nodes); | ||
505 | in | ||
506 | normalize-nodes [ | ||
507 | (flag "prefer-no-csd") | ||
508 | |||
509 | (sleaf "screenshot-path" "~/screenshots/%Y-%m-%dT%H:%M:%S.png") | ||
510 | |||
511 | (plain "hotkey-overlay" [ | ||
512 | (flag "skip-at-startup") | ||
513 | ]) | ||
514 | |||
515 | (plain "input" [ | ||
516 | (plain "keyboard" [ | ||
517 | (sleaf "repeat-delay" 300) | ||
518 | (sleaf "repeat-rate" 50) | ||
519 | |||
520 | (plain "xkb" [ | ||
521 | (sleaf "layout" "us,us") | ||
522 | (sleaf "variant" "dvp,") | ||
523 | (sleaf "options" "compose:caps,grp:win_space_toggle") | ||
524 | ]) | ||
525 | ]) | ||
526 | |||
527 | (flag "workspace-auto-back-and-forth") | ||
528 | # (sleaf "focus-follows-mouse" {}) | ||
529 | # (flag "warp-mouse-to-focus") | ||
530 | |||
531 | # (plain "touchpad" [ (flag "off") ]) | ||
532 | (plain "trackball" [ | ||
533 | (sleaf "scroll-method" "on-button-down") | ||
534 | (sleaf "scroll-button" 278) | ||
535 | ]) | ||
536 | (plain "touch" [ | ||
537 | (sleaf "map-to-output" "eDP-1") | ||
538 | ]) | ||
539 | ]) | ||
540 | |||
541 | (plain "gestures" [ | ||
542 | (plain "hot-corners" [(flag "off")]) | ||
543 | ]) | ||
544 | |||
545 | (plain "environment" (lib.mapAttrsToList sleaf { | ||
546 | NIXOS_OZONE_WL = "1"; | ||
547 | QT_QPA_PLATFORM = "wayland"; | ||
548 | QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; | ||
549 | GDK_BACKEND = "wayland"; | ||
550 | SDL_VIDEODRIVER = "wayland"; | ||
551 | DISPLAY = ":0"; | ||
552 | ELECTRON_OZONE_PLATFORM_HINT = "auto"; | ||
553 | SSH_ASKPASS_REQUIRE = "prefer"; | ||
554 | SSH_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; | ||
555 | SUDO_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; | ||
556 | })) | ||
557 | |||
558 | (node "output" ["eDP-1"] [ | ||
559 | (sleaf "scale" 1.5) | ||
560 | (sleaf "position" { x = 0; y = 0; }) | ||
561 | ]) | ||
562 | (node "output" ["Ancor Communications Inc ASUS PB287Q 0x0000DD9B"] [ | ||
563 | (sleaf "scale" 1.5) | ||
564 | (sleaf "position" { x = 2560; y = 0; }) | ||
565 | ]) | ||
566 | (node "output" ["HP Inc. HP 727pu CN4417143K"] [ | ||
567 | (sleaf "mode" "2560x1440@119.998") | ||
568 | (sleaf "scale" 1) | ||
569 | (sleaf "position" { x = 2560; y = 0; }) | ||
570 | (flag "variable-refresh-rate") | ||
571 | ]) | ||
572 | |||
573 | (plain "debug" [ | ||
574 | (sleaf "render-drm-device" "/dev/dri/by-path/pci-0000:00:02.0-render") | ||
575 | ]) | ||
576 | |||
577 | (plain "animations" [ | ||
578 | (sleaf "slowdown" 0.5) | ||
579 | (plain "workspace-switch" [(flag "off")]) | ||
580 | ]) | ||
581 | |||
582 | (plain "layout" [ | ||
583 | (sleaf "gaps" 8) | ||
584 | (plain "struts" [ | ||
585 | (sleaf "left" 26) | ||
586 | (sleaf "right" 26) | ||
587 | (sleaf "top" 0) | ||
588 | (sleaf "bottom" 0) | ||
589 | ]) | ||
590 | (plain "border" [ | ||
591 | (sleaf "width" 2) | ||
592 | (sleaf "active-gradient" { | ||
593 | from = "hsla(195 100% 45% 1)"; | ||
594 | to = "hsla(155 100% 37.5% 1)"; | ||
595 | angle = 29; | ||
596 | relative-to = "workspace-view"; | ||
597 | }) | ||
598 | (sleaf "inactive-gradient" { | ||
599 | from = "hsla(0 0% 27.7% 1)"; | ||
600 | to = "hsla(0 0% 23% 1)"; | ||
601 | angle = 29; | ||
602 | relative-to = "workspace-view"; | ||
603 | }) | ||
604 | ]) | ||
605 | (plain "focus-ring" [ | ||
606 | (flag "off") | ||
607 | ]) | ||
608 | |||
609 | (plain "preset-column-widths" (map (prop: sleaf "proportion" prop) [ | ||
610 | (1. / 4.) (1. / 3.) (1. / 2.) (2. / 3.) (3. / 4.) (1.) | ||
611 | ])) | ||
612 | (plain "default-column-width" [ (sleaf "proportion" (1. / 2.)) ]) | ||
613 | (plain "preset-window-heights" (map (prop: sleaf "proportion" prop) [ | ||
614 | (1. / 3.) (1. / 2.) (2. / 3.) (1.) | ||
615 | ])) | ||
616 | |||
617 | (flag "always-center-single-column") | ||
618 | |||
619 | (plain "tab-indicator" [ | ||
620 | (sleaf "gap" 4) | ||
621 | (sleaf "width" 8) | ||
622 | (sleaf "gaps-between-tabs" 4) | ||
623 | (flag "place-within-column") | ||
624 | (sleaf "length" { total-proportion = 1.; }) | ||
625 | (sleaf "active-gradient" { | ||
626 | from = "hsla(195 100% 60% 0.75)"; | ||
627 | to = "hsla(155 100% 50% 0.75)"; | ||
628 | angle = 29; | ||
629 | relative-to = "workspace-view"; | ||
630 | }) | ||
631 | (sleaf "inactive-gradient" { | ||
632 | from = "hsla(0 0% 42% 0.66)"; | ||
633 | to = "hsla(0 0% 35% 0.66)"; | ||
634 | angle = 29; | ||
635 | relative-to = "workspace-view"; | ||
636 | }) | ||
637 | ]) | ||
638 | ]) | ||
639 | |||
640 | (plain "cursor" [ | ||
641 | (flag "hide-when-typing") | ||
642 | ]) | ||
643 | |||
644 | (map (name: | ||
645 | (node "workspace" [name] [ | ||
646 | (sleaf "open-on-output" "eDP-1") | ||
647 | ]) | ||
648 | ) (map ({name, ...}: name) cfg.scratchspaces)) | ||
649 | (map (name: | ||
650 | (sleaf "workspace" name) | ||
651 | ) ["comm" "web" "vid" "bmr"]) | ||
652 | |||
653 | (plain "window-rule" [ | ||
654 | (sleaf "clip-to-geometry" true) | ||
655 | ]) | ||
656 | |||
657 | (plain "window-rule" [ | ||
658 | (sleaf "match" { is-floating = true; }) | ||
659 | (sleaf "geometry-corner-radius" 8) | ||
660 | (plain "shadow" [ (flag "on") ]) | ||
661 | ]) | ||
662 | |||
663 | (plain "window-rule" [ | ||
664 | (sleaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; }) | ||
665 | (sleaf "block-out-from" "screencast") | ||
666 | ]) | ||
667 | (plain "window-rule" (normalize-nodes [ | ||
668 | (map (title: | ||
669 | (sleaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; inherit title; }) | ||
670 | ) ["^Unlock Database.*" "^Access Request.*" ".*Passkey credentials$" "Browser Access Request$"]) | ||
671 | (sleaf "open-focused" true) | ||
672 | (sleaf "open-floating" true) | ||
673 | ])) | ||
674 | |||
675 | (map ({ name, match, exclude, windowRuleExtra, ... }: | ||
676 | (optional-node (match != []) (plain "window-rule" (normalize-nodes [ | ||
677 | (map (sleaf "match") match) | ||
678 | (map (sleaf "exclude") exclude) | ||
679 | (sleaf "open-on-workspace" name) | ||
680 | (sleaf "open-maximized" true) | ||
681 | windowRuleExtra | ||
682 | ]))) | ||
683 | ) cfg.scratchspaces) | ||
684 | |||
685 | (plain "window-rule" [ | ||
686 | (sleaf "match" { app-id = "^emacs$"; }) | ||
687 | (sleaf "match" { app-id = "^firefox$"; }) | ||
688 | (plain "default-column-width" [(sleaf "proportion" (2. / 3.))]) | ||
689 | ]) | ||
690 | (plain "window-rule" [ | ||
691 | (sleaf "match" { app-id = "^kitty$"; }) | ||
692 | (sleaf "match" { app-id = "^kitty-play$"; }) | ||
693 | (plain "default-column-width" [(sleaf "proportion" (1. / 3.))]) | ||
694 | ]) | ||
695 | |||
696 | (plain "window-rule" [ | ||
697 | (sleaf "match" { app-id = "^thunderbird$"; }) | ||
698 | (sleaf "match" { app-id = "^Element$"; }) | ||
699 | (sleaf "match" { app-id = "^chrome-web\.openrainbow\.com__-Default$"; }) | ||
700 | (sleaf "open-on-workspace" "comm") | ||
701 | ]) | ||
702 | (plain "window-rule" [ | ||
703 | (sleaf "match" { app-id = "^firefox$"; }) | ||
704 | (sleaf "open-on-workspace" "web") | ||
705 | (sleaf "open-maximized" true) | ||
706 | ]) | ||
707 | (plain "window-rule" [ | ||
708 | (sleaf "match" { app-id = "^mpv$"; }) | ||
709 | (sleaf "open-on-workspace" "vid") | ||
710 | (plain "default-column-width" [(sleaf "proportion" 1.)]) | ||
711 | ]) | ||
712 | (plain "window-rule" [ | ||
713 | (sleaf "match" { app-id = "^kitty-play$"; }) | ||
714 | (sleaf "open-on-workspace" "vid") | ||
715 | (sleaf "open-focused" false) | ||
716 | ]) | ||
717 | (plain "window-rule" [ | ||
718 | (sleaf "match" { app-id = "^chrome-audiobookshelf\.yggdrasil\.li__-Default$"; }) | ||
719 | (sleaf "match" { app-id = "^YouTube Music Desktop App$"; }) | ||
720 | (sleaf "open-on-workspace" "vid") | ||
721 | ]) | ||
722 | (plain "window-rule" [ | ||
723 | (sleaf "match" { app-id = "^pdfpc$"; }) | ||
724 | (plain "default-column-width" [(sleaf "proportion" 1.)]) | ||
725 | ]) | ||
726 | (plain "window-rule" [ | ||
727 | (sleaf "match" { app-id = "^pdfpc$"; title = "^.*presentation.*$"; }) | ||
728 | (plain "default-column-width" [(sleaf "proportion" 1.)]) | ||
729 | (sleaf "open-fullscreen" true) | ||
730 | (sleaf "open-on-workspace" "bmr") | ||
731 | (sleaf "open-focused" false) | ||
732 | ]) | ||
733 | (plain "window-rule" (normalize-nodes [ | ||
734 | (map (sleaf "match") [ | ||
735 | { app-id = "^Gimp-"; title = "^Quit GIMP$"; } | ||
736 | { app-id = "^org\\.kde\\.polkit-kde-authentication-agent-1$"; } | ||
737 | { app-id = "^xdg-desktop-portal-gtk$"; } | ||
738 | ]) | ||
739 | (sleaf "open-floating" true) | ||
740 | ])) | ||
741 | (plain "window-rule" [ | ||
742 | (sleaf "match" { app-id = "^org\\.pwmt\\.zathura$"; }) | ||
743 | (sleaf "match" { app-id = "^evince$"; }) | ||
744 | (sleaf "match" { app-id = "^org\\.gnome\\.Papers$"; }) | ||
745 | (sleaf "default-column-display" "tabbed") | ||
746 | ]) | ||
747 | |||
748 | (plain "layer-rule" [ | ||
749 | (sleaf "match" { namespace = "^notifications$"; }) | ||
750 | (sleaf "match" { namespace = "^waybar$"; }) | ||
751 | (sleaf "match" { namespace = "^launcher$"; }) | ||
752 | (sleaf "block-out-from" "screencast") | ||
753 | ]) | ||
754 | |||
755 | (plain "binds" | ||
756 | (let | ||
757 | bind = name: cfg: node name [(lib.removeAttrs cfg ["action"])] (lib.mapAttrsToList leaf (lib.removeAttrs cfg.action ["__functor"])); | ||
758 | in | ||
759 | normalize-nodes [ | ||
760 | (lib.mapAttrsToList bind (with config.lib.niri.actions; { | ||
761 | "Mod+Slash".action = show-hotkey-overlay; | ||
762 | |||
763 | "Mod+Return".action = spawn terminal; | ||
764 | "Mod+Shift+Return".action = | ||
765 | let | ||
766 | nushellKitty = pkgs.symlinkJoin { | ||
767 | name = "nushell-kitty"; | ||
768 | paths = [ config.programs.kitty.package ]; | ||
769 | buildInputs = [ pkgs.makeWrapper ]; | ||
770 | postBuild = '' | ||
771 | wrapProgram $out/bin/kitty \ | ||
772 | --add-flags "--config ${pkgs.writeText "kitty.conf" '' | ||
773 | include $HOME/${config.xdg.configFile."kitty/kitty.conf".target} | ||
774 | shell ${lib.getExe config.programs.nushell.package} | ||
775 | ''}" | ||
776 | ''; | ||
777 | }; | ||
778 | in spawn (lib.getExe' nushellKitty "kitty"); | ||
779 | "Mod+Q".action = close-window; | ||
780 | "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); | ||
781 | "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; | ||
782 | |||
783 | "Mod+Alt+E".action = spawn (lib.getExe' config.services.emacs.package "emacsclient") "-c"; | ||
784 | "Mod+Alt+Y".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
785 | name = "queue-yt-dlp"; | ||
786 | runtimeInputs = with pkgs; [ wl-clipboard-rs socat ]; | ||
787 | text = '' | ||
788 | socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' | ||
789 | ''; | ||
790 | })); | ||
791 | "Mod+Alt+L".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
792 | name = "queue-yt-dlp"; | ||
793 | runtimeInputs = with pkgs; [ wl-clipboard-rs config.programs.kitty.package ]; | ||
794 | text = '' | ||
795 | exec -- kitty --app-id kitty-play --directory "$HOME"/media mpv "$(wl-paste)" | ||
796 | ''; | ||
797 | })); | ||
798 | "Mod+Alt+M".action = spawn (lib.getExe' pkgs.screen-message "sm") "-n" "Fira Mono" "-a" "1" "-f" "#fff" "-b" "#000"; | ||
799 | |||
800 | "Mod+U".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
801 | name = "qalc-fuzzel"; | ||
802 | runtimeInputs = with pkgs; [ wl-clipboard-rs libqalculate config.programs.fuzzel.package coreutils findutils libnotify gnugrep ]; | ||
803 | text = '' | ||
804 | RESULTS_DIR="$HOME/.cache/qalc-fuzzel" | ||
805 | prev() { | ||
806 | FOUND=false | ||
807 | while IFS= read -r line; do | ||
808 | [[ -n "$line" ]] || continue | ||
809 | FOUND=true | ||
810 | echo "$line" | ||
811 | 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) | ||
812 | $FOUND || echo | ||
813 | } | ||
814 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> " --width=60) || exit $? | ||
815 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then | ||
816 | QALC_RES="$FUZZEL_RES" | ||
817 | QALC_RET=0 | ||
818 | else | ||
819 | QALC_RES=$(qalc -set "autocalc off" "$FUZZEL_RES" 2>&1) | ||
820 | QALC_RET=$? | ||
821 | fi | ||
822 | [[ -n "$QALC_RES" ]] || exit 1 | ||
823 | EXISTING=false | ||
824 | set +o pipefail | ||
825 | grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch | ||
826 | [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true | ||
827 | set -o pipefail | ||
828 | if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then | ||
829 | set +o pipefail | ||
830 | RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10) | ||
831 | set -o pipefail | ||
832 | cat >"$RES_FILE" <<<"$QALC_RES" | ||
833 | fi | ||
834 | [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" | ||
835 | [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" | ||
836 | notify-send "$QALC_RES" | ||
837 | ''; | ||
838 | })); | ||
839 | "Mod+Shift+U".action = | ||
840 | let | ||
841 | qalcKitty = pkgs.symlinkJoin { | ||
842 | name = "qalc-kitty"; | ||
843 | paths = [ config.programs.kitty.package ]; | ||
844 | buildInputs = [ pkgs.makeWrapper ]; | ||
845 | postBuild = '' | ||
846 | wrapProgram $out/bin/kitty \ | ||
847 | --add-flags "--config ${pkgs.writeText "kitty.conf" '' | ||
848 | include $HOME/${config.xdg.configFile."kitty/kitty.conf".target} | ||
849 | shell ${lib.getExe pkgs.libqalculate} | ||
850 | ''}" | ||
851 | ''; | ||
852 | }; | ||
853 | in spawn (lib.getExe' qalcKitty "kitty"); | ||
854 | "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
855 | name = "emoji-fuzzel"; | ||
856 | runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ]; | ||
857 | text = '' | ||
858 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " --cache "$HOME"/.cache/fuzzel-emoji --width=60 <"$HOME"/.local/share/emoji-data/list.txt) || exit $? | ||
859 | [[ -n "$FUZZEL_RES" ]] || exit 1 | ||
860 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste | ||
861 | ''; | ||
862 | })); | ||
863 | "Print".action = screenshot; | ||
864 | "Control+Print".action = screenshot-window; | ||
865 | "Shift+Print".action = kdl.magic-leaf "screenshot-screen"; | ||
866 | "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
867 | "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
868 | |||
869 | "Mod+Escape" = { | ||
870 | allow-inhibiting = false; | ||
871 | action = toggle-keyboard-shortcuts-inhibit; | ||
872 | }; | ||
873 | |||
874 | "Mod+H".action = focus-column-left; | ||
875 | "Mod+T".action = focus-window-down; | ||
876 | "Mod+N".action = focus-window-up; | ||
877 | "Mod+S".action = focus-column-right; | ||
878 | |||
879 | "Mod+Shift+H".action = move-column-left; | ||
880 | "Mod+Shift+T".action = move-window-down; | ||
881 | "Mod+Shift+N".action = move-window-up; | ||
882 | "Mod+Shift+S".action = move-column-right; | ||
883 | |||
884 | "Mod+Control+H".action = focus-monitor-left; | ||
885 | "Mod+Control+T".action = focus-monitor-down; | ||
886 | "Mod+Control+N".action = focus-monitor-up; | ||
887 | "Mod+Control+S".action = focus-monitor-right; | ||
888 | |||
889 | "Mod+Shift+Control+H".action = move-workspace-to-monitor-left; | ||
890 | "Mod+Shift+Control+T".action = move-workspace-to-monitor-down; | ||
891 | "Mod+Shift+Control+N".action = move-workspace-to-monitor-up; | ||
892 | "Mod+Shift+Control+S".action = move-workspace-to-monitor-right; | ||
893 | |||
894 | "Mod+G".action = focus-adjacent-workspace "down"; | ||
895 | "Mod+C".action = focus-adjacent-workspace "up"; | ||
896 | |||
897 | "Mod+Shift+G".action = move-column-to-adjacent-workspace "down"; | ||
898 | "Mod+Shift+C".action = move-column-to-adjacent-workspace "up"; | ||
899 | |||
900 | "Mod+Shift+Control+G".action = move-workspace-down; | ||
901 | "Mod+Shift+Control+C".action = move-workspace-up; | ||
902 | |||
903 | "Mod+ParenLeft".action = focus-workspace "comm"; | ||
904 | "Mod+Shift+ParenLeft".action = kdl.magic-leaf "move-column-to-workspace" "comm"; | ||
905 | |||
906 | "Mod+ParenRight".action = focus-workspace "web"; | ||
907 | "Mod+Shift+ParenRight".action = kdl.magic-leaf "move-column-to-workspace" "web"; | ||
908 | |||
909 | "Mod+BraceRight".action = focus-workspace "read"; | ||
910 | "Mod+Shift+BraceRight".action = kdl.magic-leaf "move-column-to-workspace" "read"; | ||
911 | |||
912 | "Mod+BraceLeft".action = focus-workspace "mon"; | ||
913 | "Mod+Shift+BraceLeft".action = kdl.magic-leaf "move-column-to-workspace" "mon"; | ||
914 | |||
915 | "Mod+Asterisk".action = focus-workspace "vid"; | ||
916 | "Mod+Shift+Asterisk".action = kdl.magic-leaf "move-column-to-workspace" "vid"; | ||
917 | |||
918 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
919 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; | ||
920 | |||
921 | "Mod+M".action = consume-or-expel-window-left; | ||
922 | "Mod+W".action = consume-or-expel-window-right; | ||
923 | |||
924 | "Mod+Shift+M".action = toggle-column-tabbed-display; | ||
925 | |||
926 | "Mod+R".action = switch-preset-column-width; | ||
927 | "Mod+Shift+R".action = maximize-column; | ||
928 | "Mod+Shift+Ctrl+R".action = switch-preset-window-height; | ||
929 | "Mod+F".action = center-column; | ||
930 | "Mod+Shift+F".action = toggle-windowed-fullscreen; | ||
931 | "Mod+Ctrl+Shift+F".action = fullscreen-window; | ||
932 | |||
933 | "Mod+V".action = switch-focus-between-floating-and-tiling; | ||
934 | "Mod+Shift+V".action = toggle-window-floating; | ||
935 | |||
936 | "Mod+Left".action = set-column-width "-10%"; | ||
937 | "Mod+Down".action = set-window-height "-10%"; | ||
938 | "Mod+Up".action = set-window-height "+10%"; | ||
939 | "Mod+Right".action = set-column-width "+10%"; | ||
940 | |||
941 | "Mod+Shift+Z" = { | ||
942 | action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; | ||
943 | allow-when-locked = true; | ||
944 | }; | ||
945 | "Mod+Shift+L".action = spawn loginctl "lock-session"; | ||
946 | "Mod+Shift+E".action = quit; | ||
947 | "Mod+Shift+Minus" = { | ||
948 | action = spawn systemctl "suspend"; | ||
949 | allow-when-locked = true; | ||
950 | }; | ||
951 | "Mod+Shift+Control+Minus" = { | ||
952 | action = spawn systemctl "hibernate"; | ||
953 | allow-when-locked = true; | ||
954 | }; | ||
955 | "Mod+Shift+P" = { | ||
956 | action = spawn (lib.getExe pkgs.playerctl) "-a" "pause"; | ||
957 | allow-when-locked = true; | ||
958 | }; | ||
959 | |||
960 | "XF86MonBrightnessUp" = { | ||
961 | action = spawn swayosd-client "--brightness" "raise"; | ||
962 | allow-when-locked = true; | ||
963 | }; | ||
964 | "XF86MonBrightnessDown" = { | ||
965 | action = spawn swayosd-client "--brightness" "lower"; | ||
966 | allow-when-locked = true; | ||
967 | }; | ||
968 | "XF86AudioRaiseVolume" = { | ||
969 | action = spawn swayosd-client "--output-volume" "raise"; | ||
970 | allow-when-locked = true; | ||
971 | }; | ||
972 | "XF86AudioLowerVolume" = { | ||
973 | action = spawn swayosd-client "--output-volume" "lower"; | ||
974 | allow-when-locked = true; | ||
975 | }; | ||
976 | "XF86AudioMute" = { | ||
977 | action = spawn swayosd-client "--output-volume" "mute-toggle"; | ||
978 | allow-when-locked = true; | ||
979 | }; | ||
980 | "XF86AudioMicMute" = { | ||
981 | action = spawn swayosd-client "--input-volume" "mute-toggle"; | ||
982 | allow-when-locked = true; | ||
983 | }; | ||
984 | |||
985 | "Mod+Semicolon".action = spawn makoctl "dismiss" "--group"; | ||
986 | "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; | ||
987 | "Mod+Period".action = spawn makoctl "menu" "--" (lib.getExe config.programs.fuzzel.package) "--dmenu"; | ||
988 | "Mod+Comma".action = spawn makoctl "restore"; | ||
989 | |||
990 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | ||
991 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}, \"focus\": true}}}"; | ||
992 | |||
993 | "Mod+X".action = set-dynamic-cast-window; | ||
994 | "Mod+Shift+X".action = set-dynamic-cast-monitor; | ||
995 | "Mod+Control+Shift+X".action = clear-dynamic-cast-target; | ||
996 | |||
997 | "Mod+D".action = with-urgent-window-action "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
998 | "Mod+Shift+D".action = with-focused-window-action "{\"Action\":{\"UnsetUrgent\":{\"id\": .id}}}"; | ||
999 | |||
1000 | "Mod+K".action = spawn (lib.getExe' pkgs.worktime "worktime-ui"); | ||
1001 | "Mod+Shift+K".action = spawn (lib.getExe' pkgs.worktime "worktime-stop"); | ||
1002 | })) | ||
1003 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) | ||
1004 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) | ||
1005 | ] | ||
1006 | )) | ||
1007 | ]; | ||
742 | }; | 1008 | }; |
743 | } | 1009 | } |
diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix index 0a10555a..703d5f7b 100644 --- a/accounts/gkleen@sif/niri/mako.nix +++ b/accounts/gkleen@sif/niri/mako.nix | |||
@@ -3,33 +3,30 @@ | |||
3 | config = { | 3 | config = { |
4 | services.mako = { | 4 | services.mako = { |
5 | enable = true; | 5 | enable = true; |
6 | font = "Fira Sans 10"; | 6 | settings = { |
7 | format = "<i>%s</i>\\n%b"; | 7 | font = "Fira Sans 10"; |
8 | margin = "2"; | 8 | format = "<i>%s</i>\\n%b"; |
9 | maxVisible = -1; | 9 | margin = "2"; |
10 | backgroundColor = "#000000dd"; | 10 | max-visible = -1; |
11 | progressColor = "source #223544ff"; | 11 | background-color = "#000000dd"; |
12 | width = 384; | 12 | progress-color = "source #223544ff"; |
13 | extraConfig = '' | 13 | width = 384; |
14 | outer-margin=1 | 14 | outer-margin = 1; |
15 | max-history=100 | 15 | max-history = 100; |
16 | max-icon-size=48 | 16 | max-icon-size = 48; |
17 | 17 | ||
18 | [grouped] | 18 | grouped.format = "<b>(%g)</b> <i>%s</i>\\n%b"; |
19 | format=<b>(%g)</b> <i>%s</i>\n%b | 19 | "urgency=low".text-color = "#999999ff"; |
20 | 20 | "urgency=critical".background-color = "#900000dd"; | |
21 | [urgency=low] | 21 | "app-name=Element".group-by = "summary"; |
22 | text-color=#999999ff | 22 | "app-name=poweralertd" = { |
23 | 23 | history = false; | |
24 | [urgency=critical] | 24 | ignore-timeout = true; |
25 | background-color=#900000dd | 25 | default-timeout = 2000; |
26 | 26 | }; | |
27 | [app-name=Element] | 27 | "app-name=worktime".history = false; |
28 | group-by=summary | 28 | "mode=silent".invisible = true; |
29 | 29 | }; | |
30 | [mode=silent] | ||
31 | invisible=1 | ||
32 | ''; | ||
33 | package = pkgs.symlinkJoin { | 30 | package = pkgs.symlinkJoin { |
34 | name = "${pkgs.mako.name}-wrapped"; | 31 | name = "${pkgs.mako.name}-wrapped"; |
35 | paths = with pkgs; [ mako ]; | 32 | paths = with pkgs; [ mako ]; |
diff --git a/accounts/gkleen@sif/niri/swayosd.nix b/accounts/gkleen@sif/niri/swayosd.nix index 984927c2..54ebb302 100644 --- a/accounts/gkleen@sif/niri/swayosd.nix +++ b/accounts/gkleen@sif/niri/swayosd.nix | |||
@@ -3,9 +3,10 @@ | |||
3 | config = { | 3 | config = { |
4 | services.swayosd = { | 4 | services.swayosd = { |
5 | enable = true; | 5 | enable = true; |
6 | topMargin = 0.946154; | 6 | topMargin = 0.4769706078; |
7 | stylePath = pkgs.runCommand "style.css" { | 7 | stylePath = pkgs.runCommand "style.css" { |
8 | src = pkgs.writeText "style.scss" '' | 8 | passAsFile = [ "src" ]; |
9 | src = '' | ||
9 | window#osd { | 10 | window#osd { |
10 | padding: 12px 20px; | 11 | padding: 12px 20px; |
11 | border-radius: 999px; | 12 | border-radius: 999px; |
@@ -59,7 +60,7 @@ | |||
59 | } | 60 | } |
60 | ''; | 61 | ''; |
61 | buildInputs = with pkgs; [sass]; | 62 | buildInputs = with pkgs; [sass]; |
62 | } "scss -C --sourcemap=none --style=compact $src $out"; | 63 | } "scss -C --sourcemap=none --style=compact $srcPath $out"; |
63 | }; | 64 | }; |
64 | }; | 65 | }; |
65 | } | 66 | } |
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix index 3f1f8119..c02a9a76 100644 --- a/accounts/gkleen@sif/niri/waybar.nix +++ b/accounts/gkleen@sif/niri/waybar.nix | |||
@@ -20,15 +20,21 @@ in { | |||
20 | { | 20 | { |
21 | layer = "top"; | 21 | layer = "top"; |
22 | position = "top"; | 22 | position = "top"; |
23 | height = 14; | 23 | height = 21; |
24 | output = [ "eDP-1" "DP-2" "DP-3" ]; | 24 | output = [ "eDP-1" "DP-2" "DP-3" ]; |
25 | modules-left = [ "niri/workspaces" ]; | 25 | modules-left = [ "niri/workspaces" ]; |
26 | modules-center = [ "niri/window" ]; | 26 | modules-center = [ "niri/window" ]; |
27 | modules-right = [ "custom/worktime" "custom/worktime-today" | 27 | modules-right = [ "custom/worktime" "custom/worktime-today" |
28 | "custom/weather" | 28 | "custom/weather" |
29 | "custom/keymap" | 29 | "custom/keymap" |
30 | "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "custom/mako" "clock" ]; | 30 | "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "custom/mako" "custom/lid_inhibitor" "clock" ]; |
31 | 31 | ||
32 | "custom/lid_inhibitor" = { | ||
33 | format = "{}"; | ||
34 | return-type = "json"; | ||
35 | exec = lib.getExe pkgs.waybar-systemd-inhibit; | ||
36 | on-click = lib.getExe' pkgs.waybar-systemd-inhibit "waybar-systemd-inhibit-toggle"; | ||
37 | }; | ||
32 | "custom/mako" = { | 38 | "custom/mako" = { |
33 | format = "{}"; | 39 | format = "{}"; |
34 | return-type = "json"; | 40 | return-type = "json"; |
@@ -131,7 +137,7 @@ in { | |||
131 | return-type = "json"; | 137 | return-type = "json"; |
132 | }; | 138 | }; |
133 | "niri/workspaces" = { | 139 | "niri/workspaces" = { |
134 | ignore = ["eff" "pwctl" "kpxc" "bmgr" "edit" "term"]; | 140 | ignore = map ({ name, ... }: name) config.programs.niri.scratchspaces; |
135 | }; | 141 | }; |
136 | "niri/window" = { | 142 | "niri/window" = { |
137 | separate-outputs = true; | 143 | separate-outputs = true; |
@@ -211,13 +217,13 @@ in { | |||
211 | layer = "top"; | 217 | layer = "top"; |
212 | position = "top"; | 218 | position = "top"; |
213 | height = 14; | 219 | height = 14; |
214 | output = [ "!eDP-1" "!DP-2" "!DP-3" ]; | 220 | output = [ "!eDP-1" "!DP-2" "!DP-3" "*" ]; |
215 | modules-left = [ "niri/workspaces" ]; | 221 | modules-left = [ "niri/workspaces" ]; |
216 | modules-center = [ "niri/window" ]; | 222 | modules-center = [ "niri/window" ]; |
217 | modules-right = [ "clock" ]; | 223 | modules-right = [ "clock" ]; |
218 | 224 | ||
219 | "niri/workspaces" = { | 225 | "niri/workspaces" = { |
220 | ignore = ["pwctl" "kpxc" "bmgr" "edit" "term"]; | 226 | ignore = map ({ name, ... }: name) config.programs.niri.scratchspaces; |
221 | }; | 227 | }; |
222 | "niri/window" = { | 228 | "niri/window" = { |
223 | separate-outputs = true; | 229 | separate-outputs = true; |
@@ -254,10 +260,10 @@ in { | |||
254 | } | 260 | } |
255 | 261 | ||
256 | .modules-left { | 262 | .modules-left { |
257 | margin-left: 12px; | 263 | margin-left: 38px; |
258 | } | 264 | } |
259 | .modules-right { | 265 | .modules-right { |
260 | margin-right: 12px; | 266 | margin-right: 38px; |
261 | } | 267 | } |
262 | 268 | ||
263 | .module { | 269 | .module { |
@@ -293,7 +299,7 @@ in { | |||
293 | #tray { | 299 | #tray { |
294 | margin: 0; | 300 | margin: 0; |
295 | } | 301 | } |
296 | #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako { | 302 | #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako, #custom-lid_inhibitor { |
297 | color: @grey; | 303 | color: @grey; |
298 | margin: 0 5px 0 2px; | 304 | margin: 0 5px 0 2px; |
299 | } | 305 | } |
@@ -302,7 +308,11 @@ in { | |||
302 | margin-left: 6px; | 308 | margin-left: 6px; |
303 | } | 309 | } |
304 | #custom-mako { | 310 | #custom-mako { |
305 | margin-right: 2px; | 311 | margin-right: 4px; |
312 | margin-left: 3px; | ||
313 | } | ||
314 | #custom-lid_inhibitor { | ||
315 | margin-right: 3px; | ||
306 | margin-left: 3px; | 316 | margin-left: 3px; |
307 | } | 317 | } |
308 | #battery { | 318 | #battery { |
@@ -330,7 +340,7 @@ in { | |||
330 | color: @orange; | 340 | color: @orange; |
331 | } | 341 | } |
332 | 342 | ||
333 | #idle_inhibitor { | 343 | #idle_inhibitor, #custom-lid_inhibitor { |
334 | padding-top: 1px; | 344 | padding-top: 1px; |
335 | } | 345 | } |
336 | 346 | ||
@@ -340,6 +350,7 @@ in { | |||
340 | } | 350 | } |
341 | #clock { | 351 | #clock { |
342 | /* margin-right: 5px; */ | 352 | /* margin-right: 5px; */ |
353 | font-feature-settings: "tnum"; | ||
343 | } | 354 | } |
344 | ''; | 355 | ''; |
345 | }; | 356 | }; |