aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/i3blocks/.local
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-09-04 18:17:31 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-09-04 18:17:31 -0500
commitb7edf26b75cf39dd6dcc52965efe35aeabdfdb7e (patch)
treea4b3b966c725e7f3fad3774f27ed996970070f93 /i3blocks/.local
parentbafd9e08317457cb60498171ac4e6476efa8e178 (diff)
fix(dunst): improve notification handling
Diffstat (limited to 'i3blocks/.local')
-rwxr-xr-xi3blocks/.local/lib/i3blocks/i3blocks-dunst21
1 files changed, 21 insertions, 0 deletions
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: