diff --git a/bin/i3-companion b/bin/i3-companion
index dc0d4f7..7ab77e4 100755
--- a/bin/i3-companion
+++ b/bin/i3-companion
@@ -885,34 +885,36 @@ async def dunst_status_check(i3, event):
@on(
DBusSignal(
interface="org.usbguard.Devices1",
- member="DevicePresenceChanged",
- signature="uuusa{ss}",
+ member="DevicePolicyApplied",
+ signature="uusua{ss}",
)
)
async def usbguard_notifications(
- i3, event, path, id, event_, target, device_rule, attributes
+ i3, event, path, id, target_new, device_rule, rule_id, attributes
):
- """Display notifications related to Network Manager state."""
+ """Display notifications related when a USBGuard policy is applied."""
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']}",
- )
+ if target_new == 0:
+ action = "accepted"
+ elif target_new == 1:
+ action = "blocked"
+ elif target_new == 2:
+ action = "rejected"
+ await notify(
+ i3,
+ app_icon="media-removable",
+ summary=f"New {action} USB device",
+ body="\n".join(
+ [
+ f"USB device {human} {action}",
+ f"ID: {id}",
+ f"Port: {attributes['via-port']}",
+ ]
+ ),
+ )
@on(