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