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