Fix USB approval alerts after policy changes and reconnects

This commit is contained in:
acrogenesis committed 2026-09-15 13:05:25 -06:00
1 parent 44f68f4329
commit 7309746ac8
3 files changed
+107 -24

No files matched your search

+2 -13
View File
@@ -7,17 +7,6 @@ set -euo pipefail
event_handler="$OMARCHY_PATH/bin/omarchy-usb-authorization-event"
# A device inserted while the graphical session was stopped is already safely
# blocked by USBGuard. Surface it now so the user can approve it after login.
while IFS= read -r line; do
if [[ $line =~ ^([0-9]+):[[:space:]](block.*)$ ]]; then
USBGUARD_IPC_SIGNAL=Device.PresenceChanged \
USBGUARD_DEVICE_ID="${BASH_REMATCH[1]}" \
USBGUARD_DEVICE_EVENT=Insert \
USBGUARD_DEVICE_TARGET=block \
USBGUARD_DEVICE_RULE="${BASH_REMATCH[2]}" \
"$event_handler"
fi
done < <(usbguard list-devices --blocked)
# The handler scans blocked devices on IPC.Connected, including reconnects
# after a daemon restart, once the event subscription is established.
exec usbguard watch --wait --exec "$event_handler"