mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-03 09:44:28 +02:00
i3-companion: implement usbguard notifications
This commit is contained in:
parent
e3d7e4da56
commit
ab391e9ebf
1 changed files with 33 additions and 0 deletions
|
@ -882,6 +882,39 @@ async def dunst_status_check(i3, event):
|
||||||
return icons[paused and "notifications-disabled" or "notifications-enabled"]
|
return icons[paused and "notifications-disabled" or "notifications-enabled"]
|
||||||
|
|
||||||
|
|
||||||
|
@on(
|
||||||
|
DBusSignal(
|
||||||
|
interface="org.usbguard.Devices1",
|
||||||
|
member="DevicePresenceChanged",
|
||||||
|
signature="uuusa{ss}",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
async def usbguard_notifications(
|
||||||
|
i3, event, path, id, event_, target, device_rule, attributes
|
||||||
|
):
|
||||||
|
"""Display notifications related to Network Manager state."""
|
||||||
|
if attributes["name"]:
|
||||||
|
human = f"\"{attributes['name']}\" ({attributes['id']})"
|
||||||
|
else:
|
||||||
|
human = f"{attributes['id']}"
|
||||||
|
if event_ == 1:
|
||||||
|
# Insertion
|
||||||
|
await notify(
|
||||||
|
i3,
|
||||||
|
app_icon="media-removable",
|
||||||
|
summary="New USB device",
|
||||||
|
body=f"USB device {human} inserted\non port {attributes['via-port']}",
|
||||||
|
)
|
||||||
|
elif event_ == 3:
|
||||||
|
# Removal
|
||||||
|
await notify(
|
||||||
|
i3,
|
||||||
|
app_icon="media-removable",
|
||||||
|
summary="Removed USB device",
|
||||||
|
body=f"USB device {human} removed\nfrom port {attributes['via-port']}",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@on(
|
@on(
|
||||||
DBusSignal(
|
DBusSignal(
|
||||||
interface="org.freedesktop.NetworkManager.Connection.Active",
|
interface="org.freedesktop.NetworkManager.Connection.Active",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue