fx: wyabar notifs module

This commit is contained in:
2026-10-07 11:48:30 +02:00
parent 148e4267d5
commit 30938eeaee

View File

@@ -6,21 +6,29 @@ from json import dumps
from dbus_fast.aio import MessageBus from dbus_fast.aio import MessageBus
from dbus_fast.proxy_object import BaseProxyInterface, BaseProxyObject from dbus_fast.proxy_object import BaseProxyInterface, BaseProxyObject
def output(msg: string, clss: string = "unmuted-notifs"):
print(dumps({
"text": msg,
"alt": "",
"tooltip": "",
"class": clss,
"percentage": 0
}, ensure_ascii=False), flush=True)
def update_dbus_state(interface, changed, _) -> None: def update_dbus_state(interface, changed, _) -> None:
if interface != 'org.dunstproject.cmd0': if interface != 'org.dunstproject.cmd0':
output("", "error")
return return
if 'paused' in changed: if 'paused' in changed:
update_output(changed['paused'].value) update_output(changed['paused'].value)
def update_output(paused: bool) -> None: def update_output(paused: bool) -> None:
print(dumps({ output("󱙍" if paused else "󰍡", "muted-notifs" if paused else "unmuted-notifs")
"text": "󱙍" if paused else "󰍡",
"alt": "",
"tooltip": "",
"class": "muted-notifs" if paused else "unmuted-notifs",
"percentage": 0
}, ensure_ascii=False))
async def main() -> None: async def main() -> None:
bus = await MessageBus().connect() bus = await MessageBus().connect()
@@ -37,6 +45,6 @@ async def main() -> None:
await Event().wait() await Event().wait()
if __name__ == "__main__": if __name__ == "__main__":
run(main()) run(main())