summaryrefslogtreecommitdiff
path: root/accounts
diff options
context:
space:
mode:
Diffstat (limited to 'accounts')
-rw-r--r--accounts/gkleen@sif/default.nix3
-rw-r--r--accounts/gkleen@sif/niri/default.nix104
-rw-r--r--accounts/gkleen@sif/niri/mako.nix2
-rw-r--r--accounts/gkleen@sif/niri/swayosd.nix7
4 files changed, 106 insertions, 10 deletions
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix
index e07362fc..36a81f83 100644
--- a/accounts/gkleen@sif/default.nix
+++ b/accounts/gkleen@sif/default.nix
@@ -320,6 +320,9 @@ in {
320 "kitty_mod+n" = "detach_window"; 320 "kitty_mod+n" = "detach_window";
321 "kitty_mod+m" = "detach_window ask"; 321 "kitty_mod+m" = "detach_window ask";
322 }; 322 };
323 extraConfig = ''
324 envinclude KITTY_CONF_*
325 '';
323 }; 326 };
324 fuzzel = { 327 fuzzel = {
325 enable = true; 328 enable = true;
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
index 803b3a0d..af1af07a 100644
--- a/accounts/gkleen@sif/niri/default.nix
+++ b/accounts/gkleen@sif/niri/default.nix
@@ -245,7 +245,7 @@ in {
245 Service = { 245 Service = {
246 Type = "simple"; 246 Type = "simple";
247 Sockets = [ "niri-workspace-history.socket" ]; 247 Sockets = [ "niri-workspace-history.socket" ];
248 ExecStart = pkgs.writers.writePython3 "niri-workspace-history" {} '' 248 ExecStart = pkgs.writers.writePython3 "niri-workspace-history" { flakeIgnore = ["E501"]; } ''
249 import os 249 import os
250 import socket 250 import socket
251 import json 251 import json
@@ -274,7 +274,7 @@ in {
274 274
275 def focus_workspace(output, workspace): 275 def focus_workspace(output, workspace):
276 with history_lock: 276 with history_lock:
277 workspace_history[output] = [workspace] + [ws for ws in workspace_history[output] if ws != workspace] # noqa: E501 277 workspace_history[output] = [workspace] + [ws for ws in workspace_history[output] if ws != workspace]
278 # print(json.dumps(workspace_history), file=sys.stderr) 278 # print(json.dumps(workspace_history), file=sys.stderr)
279 279
280 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 280 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -297,14 +297,14 @@ in {
297 297
298 class RequestHandler(StreamRequestHandler): 298 class RequestHandler(StreamRequestHandler):
299 def handle(self): 299 def handle(self):
300 with detaching(TextIOWrapper(self.wfile, encoding='utf-8', write_through=True)) as out: # noqa: E501 300 with detaching(TextIOWrapper(self.wfile, encoding='utf-8', write_through=True)) as out:
301 with history_lock: 301 with history_lock:
302 json.dump(workspace_history, out) 302 json.dump(workspace_history, out)
303 303
304 304
305 class Server(ThreadingTCPServer): 305 class Server(ThreadingTCPServer):
306 def __init__(self): 306 def __init__(self):
307 ThreadingTCPServer.__init__(self, ("", 8000), RequestHandler, bind_and_activate=False) # noqa: E501 307 ThreadingTCPServer.__init__(self, ("", 8000), RequestHandler, bind_and_activate=False)
308 self.socket = socket.fromfd(3, self.address_family, self.socket_type) 308 self.socket = socket.fromfd(3, self.address_family, self.socket_type)
309 309
310 310
@@ -330,6 +330,79 @@ in {
330 ''; 330 '';
331 }; 331 };
332 }; 332 };
333 systemd.user.services.niri-workspace-sort = {
334 Unit = {
335 BindsTo = [ "niri.service" ];
336 After = [ "niri.service" ];
337 };
338 Install = {
339 WantedBy = [ "niri.service" ];
340 };
341 Service = {
342 Type = "simple";
343 ExecStart = pkgs.writers.writePython3 "niri-workspace-sort" { flakeIgnore = ["E501"]; } ''
344 import os
345 import sys
346 import socket
347 import json
348
349 outputs = None
350 only = {'HDMI-A-1': {'bmr'}, 'eDP-1': {'vid'}}
351
352
353 class Niri(socket.socket):
354 def __init__(self):
355 super().__init__(socket.AF_UNIX, socket.SOCK_STREAM)
356 super().connect(os.environ["NIRI_SOCKET"])
357 self.fh = super().makefile(mode='rw', buffering=1, encoding='utf-8')
358
359 def cmd(self, obj):
360 print(json.dumps(obj, separators=(',', ':')), flush=True, file=self.fh)
361
362 def event_stream(self):
363 self.cmd("EventStream")
364 return self.fh
365
366
367 with Niri() as niri, Niri().event_stream() as niri_stream:
368 for line in niri_stream:
369 workspaces = None
370 if line_json := json.loads(line):
371 if "WorkspacesChanged" in line_json:
372 workspaces = line_json["WorkspacesChanged"]["workspaces"]
373
374 if workspaces is None:
375 continue
376
377 old_outputs = outputs
378 outputs = {ws["output"] for ws in workspaces}
379 if old_outputs is None:
380 print("Initial outputs: {}".format(outputs), file=sys.stderr)
381 continue
382
383 new_outputs = outputs - old_outputs
384 if not new_outputs:
385 continue
386 print("New outputs: {}".format(new_outputs), file=sys.stderr)
387
388 relevant_workspaces = list(filter(lambda ws: (ws["name"] is not None) or (ws["active_window_id"] is not None), workspaces))
389 target_output = next(iter(outputs - set(only.keys())))
390 if not target_output:
391 continue
392 for ws in relevant_workspaces:
393 ws_ident = ws["name"] if ws["name"] is not None else (ws["output"], ws["idx"])
394 if ws["output"] not in set(only.keys()):
395 continue
396 if ws_ident in only[ws["output"]]:
397 continue
398
399 print("{} -> {}".format(ws_ident, target_output), file=sys.stderr)
400 niri.cmd({"Action": {"MoveWorkspaceToMonitor": {"reference": {"Id": ws["id"]}, "output": target_output}}})
401 '';
402 Restart = "on-failure";
403 RestartSec = 10;
404 };
405 };
333 406
334 programs.niri.scratchspaces = [ 407 programs.niri.scratchspaces = [
335 { name = "pwctl"; 408 { name = "pwctl";
@@ -415,6 +488,10 @@ in {
415 ]) 488 ])
416 ]) 489 ])
417 490
491 (plain "gestures" [
492 (plain "hot-corners" [(flag "off")])
493 ])
494
418 (plain "environment" (lib.mapAttrsToList leaf { 495 (plain "environment" (lib.mapAttrsToList leaf {
419 NIXOS_OZONE_WL = "1"; 496 NIXOS_OZONE_WL = "1";
420 QT_QPA_PLATFORM = "wayland"; 497 QT_QPA_PLATFORM = "wayland";
@@ -422,6 +499,7 @@ in {
422 GDK_BACKEND = "wayland"; 499 GDK_BACKEND = "wayland";
423 SDL_VIDEODRIVER = "wayland"; 500 SDL_VIDEODRIVER = "wayland";
424 DISPLAY = ":0"; 501 DISPLAY = ":0";
502 ELECTRON_OZONE_PLATFORM_HINT = "auto";
425 })) 503 }))
426 504
427 (node "output" "eDP-1" [ 505 (node "output" "eDP-1" [
@@ -633,7 +711,21 @@ in {
633 "Mod+Slash".action = show-hotkey-overlay; 711 "Mod+Slash".action = show-hotkey-overlay;
634 712
635 "Mod+Return".action = spawn terminal; 713 "Mod+Return".action = spawn terminal;
636 "Mod+Shift+Return".action = spawn terminal (lib.getExe config.programs.nushell.package); 714 "Mod+Shift+Return".action =
715 let
716 nushellKitty = pkgs.symlinkJoin {
717 name = "nushell-kitty";
718 paths = [ config.programs.kitty.package ];
719 buildInputs = [ pkgs.makeWrapper ];
720 postBuild = ''
721 wrapProgram $out/bin/kitty \
722 --add-flags "--config ${pkgs.writeText "kitty.conf" ''
723 include $HOME/${config.xdg.configFile."kitty/kitty.conf".target}
724 shell ${lib.getExe config.programs.nushell.package}
725 ''}"
726 '';
727 };
728 in spawn (lib.getExe' nushellKitty "kitty");
637 "Mod+Q".action = close-window; 729 "Mod+Q".action = close-window;
638 "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); 730 "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package);
639 "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; 731 "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path";
@@ -705,7 +797,7 @@ in {
705 })); 797 }));
706 "Print".action = screenshot; 798 "Print".action = screenshot;
707 "Control+Print".action = screenshot-window; 799 "Control+Print".action = screenshot-window;
708 # "Shift+Print".action = screenshot-screen; 800 "Shift+Print".action = kdl.magic-leaf "screenshot-screen";
709 "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; 801 "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}";
710 "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; 802 "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}";
711 803
diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix
index 9373dc21..274441ab 100644
--- a/accounts/gkleen@sif/niri/mako.nix
+++ b/accounts/gkleen@sif/niri/mako.nix
@@ -16,7 +16,7 @@
16 max-icon-size = 48; 16 max-icon-size = 48;
17 }; 17 };
18 criteria = { 18 criteria = {
19 grouped.format = "<b>(%g)</b> <i>%s</i>\n%b"; 19 grouped.format = "<b>(%g)</b> <i>%s</i>\\n%b";
20 "urgency=low".text-color = "#999999ff"; 20 "urgency=low".text-color = "#999999ff";
21 "urgency=critical".background-color = "#900000dd"; 21 "urgency=critical".background-color = "#900000dd";
22 "app-name=Element".group-by = "summary"; 22 "app-name=Element".group-by = "summary";
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}