scripts reorganize
This commit is contained in:
42
scripts/WMScripts/dunst_bar.py
Executable file
42
scripts/WMScripts/dunst_bar.py
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --packages python314Packages.dbus-fast
|
||||
|
||||
from asyncio import run, Event
|
||||
from json import dumps
|
||||
from dbus_fast.aio import MessageBus
|
||||
from dbus_fast.proxy_object import BaseProxyInterface, BaseProxyObject
|
||||
|
||||
def update_dbus_state(interface, changed, _) -> None:
|
||||
if interface != 'org.dunstproject.cmd0':
|
||||
return
|
||||
|
||||
if 'paused' in changed:
|
||||
update_output(changed['paused'].value)
|
||||
|
||||
def update_output(paused: bool) -> None:
|
||||
print(dumps({
|
||||
"text": "" if paused else "",
|
||||
"alt": "",
|
||||
"tooltip": "",
|
||||
"class": "muted-notifs" if paused else "unmuted-notifs",
|
||||
"percentage": 0
|
||||
}, ensure_ascii=False))
|
||||
|
||||
async def main() -> None:
|
||||
bus = await MessageBus().connect()
|
||||
|
||||
introspection = await bus.introspect('org.freedesktop.Notifications', '/org/freedesktop/Notifications')
|
||||
notifications: BaseProxyObject = bus.get_proxy_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications', introspection)
|
||||
|
||||
properties = notifications.get_interface('org.freedesktop.DBus.Properties')
|
||||
dunst = notifications.get_interface('org.dunstproject.cmd0')
|
||||
|
||||
properties.on_properties_changed(update_dbus_state)
|
||||
|
||||
update_output(await dunst.get_paused())
|
||||
|
||||
await Event().wait()
|
||||
|
||||
if __name__ == "__main__":
|
||||
run(main())
|
||||
|
||||
Reference in New Issue
Block a user