mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-24 18:58:33 +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(
|
@on(
|
||||||
DBusSignal(
|
DBusSignal(
|
||||||
interface="org.usbguard.Devices1",
|
interface="org.usbguard.Devices1",
|
||||||
member="DevicePresenceChanged",
|
member="DevicePolicyApplied",
|
||||||
signature="uuusa{ss}",
|
signature="uusua{ss}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
async def usbguard_notifications(
|
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"]:
|
if attributes["name"]:
|
||||||
human = f"\"{attributes['name']}\" ({attributes['id']})"
|
human = f"\"{attributes['name']}\" ({attributes['id']})"
|
||||||
else:
|
else:
|
||||||
human = f"{attributes['id']}"
|
human = f"{attributes['id']}"
|
||||||
if event_ == 1:
|
if target_new == 0:
|
||||||
# Insertion
|
action = "accepted"
|
||||||
await notify(
|
elif target_new == 1:
|
||||||
i3,
|
action = "blocked"
|
||||||
app_icon="media-removable",
|
elif target_new == 2:
|
||||||
summary="New USB device",
|
action = "rejected"
|
||||||
body=f"USB device {human} inserted\non port {attributes['via-port']}",
|
await notify(
|
||||||
)
|
i3,
|
||||||
elif event_ == 3:
|
app_icon="media-removable",
|
||||||
# Removal
|
summary=f"New {action} USB device",
|
||||||
await notify(
|
body="\n".join(
|
||||||
i3,
|
[
|
||||||
app_icon="media-removable",
|
f"USB device {human} {action}",
|
||||||
summary="Removed USB device",
|
f"ID: <tt>{id}</tt>",
|
||||||
body=f"USB device {human} removed\nfrom port {attributes['via-port']}",
|
f"Port: <tt>{attributes['via-port']}</tt>",
|
||||||
)
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@on(
|
@on(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue