i3-companion: remove duplicate code

This commit is contained in:
Vincent Bernat 2021-07-18 09:13:57 +02:00
parent b6ab2d3c12
commit 5994b8a0fd

View file

@ -628,7 +628,7 @@ async def bluetooth_notifications(i3, event, path, interface, changed, invalid):
@retry(2) @retry(2)
@debounce(0.2) @debounce(0.2)
async def bluetooth_status(i3, event, *args): async def bluetooth_status(i3, event, *args):
"""Update bluetooth status for polybar.""" """Update bluetooth status for Polybar."""
if event is StartEvent: if event is StartEvent:
# Do we have a bluetooth device? # Do we have a bluetooth device?
if not os.path.exists("/sys/class/bluetooth"): if not os.path.exists("/sys/class/bluetooth"):
@ -720,11 +720,7 @@ async def bluetooth_status(i3, event, *args):
) )
) )
async def dunst_status_update(i3, event, path, interface, changed, invalid): async def dunst_status_update(i3, event, path, interface, changed, invalid):
"""Update notification status in polybar.""" """Update notification status in Polybar."""
if interface != "org.dunstproject.cmd0":
return
if "paused" not in changed:
return
polybar( polybar(
"dunst", "dunst",
icons[ icons[
@ -735,14 +731,13 @@ async def dunst_status_update(i3, event, path, interface, changed, invalid):
@on(StartEvent) @on(StartEvent)
async def dunst_status_check(i3, event): async def dunst_status_check(i3, event):
"""Display notification status for polybar.""" """Display notification status for Polybar."""
conn = i3.session_bus["org.freedesktop.Notifications"] conn = i3.session_bus["org.freedesktop.Notifications"]
obj = conn["/org/freedesktop/Notifications"] obj = conn["/org/freedesktop/Notifications"]
dunst = await obj.get_async_interface("org.dunstproject.cmd0") dunst = await obj.get_async_interface("org.dunstproject.cmd0")
paused = await dunst.paused paused = await dunst.paused
polybar( polybar(
"dunst", "dunst", icons[paused and "notifications-disabled" or "notifications-enabled"]
icons[paused and "notifications-disabled" or "notifications-enabled"],
) )