summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/niri/mako.nix
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/niri/mako.nix')
-rw-r--r--accounts/gkleen@sif/niri/mako.nix67
1 files changed, 66 insertions, 1 deletions
diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix
index 8abf14d8..0a10555a 100644
--- a/accounts/gkleen@sif/niri/mako.nix
+++ b/accounts/gkleen@sif/niri/mako.nix
@@ -1,4 +1,4 @@
1{ config, lib, ... }: 1{ config, lib, pkgs, ... }:
2{ 2{
3 config = { 3 config = {
4 services.mako = { 4 services.mako = {
@@ -13,6 +13,7 @@
13 extraConfig = '' 13 extraConfig = ''
14 outer-margin=1 14 outer-margin=1
15 max-history=100 15 max-history=100
16 max-icon-size=48
16 17
17 [grouped] 18 [grouped]
18 format=<b>(%g)</b> <i>%s</i>\n%b 19 format=<b>(%g)</b> <i>%s</i>\n%b
@@ -29,6 +30,14 @@
29 [mode=silent] 30 [mode=silent]
30 invisible=1 31 invisible=1
31 ''; 32 '';
33 package = pkgs.symlinkJoin {
34 name = "${pkgs.mako.name}-wrapped";
35 paths = with pkgs; [ mako ];
36 inherit (pkgs.mako) meta;
37 postBuild = ''
38 rm -r $out/share/dbus-1
39 '';
40 };
32 }; 41 };
33 systemd.user.services.mako = { 42 systemd.user.services.mako = {
34 Unit = { 43 Unit = {
@@ -46,5 +55,61 @@
46 Restart = "always"; 55 Restart = "always";
47 }; 56 };
48 }; 57 };
58
59 systemd.user.services.mako-follows-focus = {
60 Unit = {
61 BindsTo = [ "niri.service" "mako.service" ];
62 After = [ "niri.service" "mako.service" ];
63 };
64 Service = {
65 Type = "simple";
66 Restart = "always";
67 ExecStart = pkgs.writers.writePython3 "mako-follows-focus" {
68 libraries = with pkgs.python3Packages; [];
69 } ''
70 import os
71 import socket
72 import json
73 import subprocess
74
75
76 current_output = None
77 workspaces = []
78
79
80 def output_changed(new_output):
81 global current_output
82
83 if current_output == new_output:
84 return
85
86 current_output = new_output
87 subprocess.run(["makoctl", "reload"])
88
89
90 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
91 sock.connect(os.environ["NIRI_SOCKET"])
92 sock.send(b"\"EventStream\"\n")
93 for line in sock.makefile(buffering=1, encoding='utf-8'):
94 if line_json := json.loads(line):
95 if "WorkspacesChanged" in line_json:
96 workspaces = line_json["WorkspacesChanged"]["workspaces"]
97 for workspace in workspaces:
98 if not workspace["is_focused"]:
99 continue
100 output_changed(workspace["output"])
101 break
102 if "WorkspaceActivated" in line_json and line_json["WorkspaceActivated"]["focused"]: # noqa: E501
103 for workspace in workspaces:
104 if not workspace["id"] == line_json["WorkspaceActivated"]["id"]: # noqa: E501
105 continue
106 output_changed(workspace["output"])
107 break
108 '';
109 };
110 Install = {
111 WantedBy = [ "mako.service" ];
112 };
113 };
49 }; 114 };
50} 115}