blob: 8fbc81c15019fc5a04780060557d9dc3c08a988f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
{ config, lib, pkgs, ... }:
{
config = {
services.mako = {
enable = true;
font = "Fira Sans 10";
format = "<i>%s</i>\\n%b";
margin = "2";
maxVisible = -1;
backgroundColor = "#000000dd";
progressColor = "source #223544ff";
width = 384;
extraConfig = ''
outer-margin=1
max-history=100
max-icon-size=48
[grouped]
format=<b>(%g)</b> <i>%s</i>\n%b
[urgency=low]
text-color=#999999ff
[urgency=critical]
background-color=#900000dd
[app-name=Element]
group-by=summary
[mode=silent]
invisible=1
'';
};
systemd.user.services.mako = {
Unit = {
Description = "Mako notification daemon";
PartOf = [ "graphical-session.target" ];
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
Type = "dbus";
BusName = "org.freedesktop.Notifications";
ExecStart = lib.getExe config.services.mako.package;
RestartSec = 5;
Restart = "always";
};
};
systemd.user.services.mako-follows-focus = {
Unit = {
BindsTo = [ "niri.service" "mako.service" ];
After = [ "niri.service" "mako.service" ];
};
Service = {
Type = "simple";
Restart = "always";
ExecStart = pkgs.writers.writePython3 "mako-follows-focus" {
libraries = with pkgs.python3Packages; [];
} ''
import os
import socket
import json
import subprocess
current_output = None
workspaces = []
def output_changed(new_output):
global current_output
if current_output == new_output:
return
current_output = new_output
subprocess.run(["makoctl", "reload"])
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(os.environ["NIRI_SOCKET"])
sock.send(b"\"EventStream\"\n")
for line in sock.makefile(buffering=1, encoding='utf-8'):
if line_json := json.loads(line):
if "WorkspacesChanged" in line_json:
workspaces = line_json["WorkspacesChanged"]["workspaces"]
for workspace in workspaces:
if not workspace["is_focused"]:
continue
output_changed(workspace["output"])
break
if "WorkspaceActivated" in line_json and line_json["WorkspaceActivated"]["focused"]: # noqa: E501
for workspace in workspaces:
if not workspace["id"] == line_json["WorkspaceActivated"]["id"]: # noqa: E501
continue
output_changed(workspace["output"])
break
'';
};
Install = {
WantedBy = [ "mako.service" ];
};
};
};
}
|