summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/niri/waybar.nix
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/niri/waybar.nix')
-rw-r--r--accounts/gkleen@sif/niri/waybar.nix58
1 files changed, 56 insertions, 2 deletions
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix
index ff48ba83..26e76a1d 100644
--- a/accounts/gkleen@sif/niri/waybar.nix
+++ b/accounts/gkleen@sif/niri/waybar.nix
@@ -25,8 +25,58 @@
25 modules-right = [ # "custom/worktime" "custom/worktime-today" 25 modules-right = [ # "custom/worktime" "custom/worktime-today"
26 "custom/weather" 26 "custom/weather"
27 "custom/keymap" 27 "custom/keymap"
28 "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ]; 28 "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "custom/mako" "clock" ];
29 29
30 "custom/mako" = {
31 format = "{}";
32 return-type = "json";
33 exec = pkgs.writers.writePython3 "mako-silent" { libraries = [ pkgs.python3Packages.dbus-next ]; } ''
34 from dbus_next.aio import MessageBus
35
36 import asyncio
37
38 import json
39
40
41 loop = asyncio.new_event_loop()
42 asyncio.set_event_loop(loop)
43
44
45 async def main():
46 bus = await MessageBus().connect()
47 # the introspection xml would normally be included in your project, but
48 # this is convenient for development
49 introspection = await bus.introspect('org.freedesktop.Notifications', '/fr/emersion/Mako') # noqa: E501
50
51 obj = bus.get_proxy_object('org.freedesktop.Notifications', '/fr/emersion/Mako', introspection) # noqa: E501
52 mako = obj.get_interface('fr.emersion.Mako')
53 properties = obj.get_interface('org.freedesktop.DBus.Properties')
54
55 async def print_mode():
56 modes = await mako.get_modes()
57 is_silent = "silent" in modes
58 icon = "󰂛" if is_silent else "󰂚"
59 text = f"<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>" # noqa: E501
60 if is_silent:
61 text = f"<span color=\"#ffffff\">{text}</span>"
62 print(json.dumps({'text': text}, separators=(',', ':')), flush=True) # noqa: E501
63
64 async def on_properties_changed(interface_name, changed_properties, invalidated_properties): # noqa: E501
65 if "Modes" not in invalidated_properties:
66 return
67
68 await print_mode()
69
70 properties.on_properties_changed(on_properties_changed)
71 await print_mode()
72
73 await loop.create_future()
74
75
76 loop.run_until_complete(main())
77 '';
78 on-click = "makoctl mode -t silent";
79 };
30 "custom/weather" = { 80 "custom/weather" = {
31 format = "{}"; 81 format = "{}";
32 tooltip = true; 82 tooltip = true;
@@ -240,11 +290,15 @@
240 #tray { 290 #tray {
241 margin: 0; 291 margin: 0;
242 } 292 }
243 #battery, #idle_inhibitor, #backlight, #wireplumber { 293 #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako {
244 color: @grey; 294 color: @grey;
245 margin: 0 5px 0 2px; 295 margin: 0 5px 0 2px;
246 } 296 }
247 #idle_inhibitor { 297 #idle_inhibitor {
298 margin-right: 4px;
299 margin-left: 6px;
300 }
301 #custom-mako {
248 margin-right: 2px; 302 margin-right: 2px;
249 margin-left: 3px; 303 margin-left: 3px;
250 } 304 }