mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-24 10:48:35 +02:00
i3-companion: display applied policy for usbguard notifications
This commit is contained in:
parent
ab391e9ebf
commit
ba33d4499a
1 changed files with 22 additions and 20 deletions
|
@ -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: <tt>{id}</tt>",
|
||||
f"Port: <tt>{attributes['via-port']}</tt>",
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@on(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue