summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accounts/gkleen@sif/niri/default.nix88
-rw-r--r--accounts/gkleen@sif/niri/mako.nix2
-rw-r--r--accounts/gkleen@sif/niri/swayosd.nix7
-rw-r--r--hosts/surtr/email/default.nix1
-rw-r--r--hosts/vidhar/prometheus/default.nix2
5 files changed, 90 insertions, 10 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
index 803b3a0d..924d3843 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" [
@@ -705,7 +783,7 @@ in {
705 })); 783 }));
706 "Print".action = screenshot; 784 "Print".action = screenshot;
707 "Control+Print".action = screenshot-window; 785 "Control+Print".action = screenshot-window;
708 # "Shift+Print".action = screenshot-screen; 786 "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}}}"; 787 "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}}}"; 788 "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}";
711 789
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}
diff --git a/hosts/surtr/email/default.nix b/hosts/surtr/email/default.nix
index 4666d1d6..845f6455 100644
--- a/hosts/surtr/email/default.nix
+++ b/hosts/surtr/email/default.nix
@@ -364,6 +364,7 @@ in {
364 domains = [ "surtr.yggdrasil.li" ] ++ concatMap (domain: [".${domain}" domain]) emailDomains; 364 domains = [ "surtr.yggdrasil.li" ] ++ concatMap (domain: [".${domain}" domain]) emailDomains;
365 separator = "+"; 365 separator = "+";
366 extraConfig = '' 366 extraConfig = ''
367 socketmap = unix:/run/postsrsd/postsrsd-socketmap.sock
367 milter = unix:/run/postsrsd/postsrsd-milter.sock 368 milter = unix:/run/postsrsd/postsrsd-milter.sock
368 ''; 369 '';
369 }; 370 };
diff --git a/hosts/vidhar/prometheus/default.nix b/hosts/vidhar/prometheus/default.nix
index d368ad52..b1d90d47 100644
--- a/hosts/vidhar/prometheus/default.nix
+++ b/hosts/vidhar/prometheus/default.nix
@@ -26,7 +26,7 @@ in {
26 enable = true; 26 enable = true;
27 27
28 extraFlags = [ 28 extraFlags = [
29 "--enable-feature=remote-write-receiver" 29 "--web.enable-remote-write-receiver"
30 ]; 30 ];
31 31
32 exporters = { 32 exporters = {