From b7edf26b75cf39dd6dcc52965efe35aeabdfdb7e Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Wed, 4 Sep 2024 18:17:31 -0500 Subject: fix(dunst): improve notification handling --- i3blocks/.local/lib/i3blocks/i3blocks-dunst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'i3blocks/.local') diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-dunst b/i3blocks/.local/lib/i3blocks/i3blocks-dunst index c2b07db..a683adf 100755 --- a/i3blocks/.local/lib/i3blocks/i3blocks-dunst +++ b/i3blocks/.local/lib/i3blocks/i3blocks-dunst @@ -6,12 +6,20 @@ import sys import json from dbus_next.aio import MessageBus +import i3ipc +from i3ipc.aio import Connection BUS_NAME = "org.freedesktop.Notifications" OBJECT_PATH = "/org/freedesktop/Notifications" DUNST_INTERFACE = "org.dunstproject.cmd0" PROPERTIES_INTERFACE = "org.freedesktop.DBus.Properties" +I3_EVENTS = [ + i3ipc.Event.WINDOW_FOCUS, + i3ipc.Event.WINDOW_FULLSCREEN_MODE, + i3ipc.Event.WINDOW_CLOSE, + i3ipc.Event.WORKSPACE_FOCUS, +] class Dunst: @@ -31,8 +39,20 @@ class Dunst: self.displayed = await self.dunst.get_displayed_length() self.waiting = await self.dunst.get_waiting_length() + self.i3 = await Connection().connect() + + for event in I3_EVENTS: + self.i3.on(event, self.handle_i3_event) + return self + async def handle_i3_event(self, conn, e): + if e.container is None or e.change == "close": + await self.dunst.call_rule_enable("transient_skip", 0) + else: + await self.dunst.call_rule_enable("transient_skip", e.container.fullscreen_mode) + + def print_status(self): if self.paused: icon = "\U000f009b" # 󰂛 @@ -110,6 +130,7 @@ async def main(): try: async with asyncio.TaskGroup() as task_group: + task_group.create_task(dunst.i3.main()) task_group.create_task(dunst.listener()) task_group.create_task(dunst.button_handler()) except asyncio.CancelledError: -- cgit v1.2.3-70-g09d2