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