Fix usbguard-notify.py
This commit is contained in:
parent
0da5137978
commit
4067e215fe
@ -54,26 +54,26 @@ def get_name_and_id_from_rule(rule):
|
|||||||
|
|
||||||
def prompt_device_action(dev_id, name, long_id):
|
def prompt_device_action(dev_id, name, long_id):
|
||||||
proc = Popen([DUNSTIFY_EXEC_NAME, '-p',
|
proc = Popen([DUNSTIFY_EXEC_NAME, '-p',
|
||||||
'-A', '2,Block',
|
'-A', 'block,Block',
|
||||||
'-A', '1,Allow',
|
'-A', 'allow,Allow',
|
||||||
'-A', '0,Reject',
|
'-A', 'reject,Reject',
|
||||||
f'{name} ({long_id})',
|
f'{name} ({long_id})',
|
||||||
'New Device'],
|
'New Device'],
|
||||||
stdout=PIPE, text=True, bufsize=0)
|
stdout=PIPE, text=True, bufsize=0)
|
||||||
open_notifications[dev_id] = int(proc.stdout.readline())
|
open_notifications[dev_id] = int(proc.stdout.readline())
|
||||||
option = int(proc.communicate()[0])
|
option = proc.communicate()[0][:-1]
|
||||||
try:
|
try:
|
||||||
open_notifications.pop(dev_id)
|
open_notifications.pop(dev_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
match option:
|
match option:
|
||||||
case 0:
|
case 'reject':
|
||||||
run([USBGUARD_EXEC_NAME, 'reject-device', long_id])
|
run([USBGUARD_EXEC_NAME, 'reject-device', long_id])
|
||||||
|
|
||||||
case 1:
|
case 'allow':
|
||||||
run([USBGUARD_EXEC_NAME, 'allow-device', long_id])
|
run([USBGUARD_EXEC_NAME, 'allow-device', long_id])
|
||||||
|
|
||||||
case 2:
|
case _:
|
||||||
run([USBGUARD_EXEC_NAME, 'block-device', long_id])
|
run([USBGUARD_EXEC_NAME, 'block-device', long_id])
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user