Compare commits

...

2 Commits

Author SHA1 Message Date
Zander671 4d5ebe465e Merge branch 'main' of git.zander.im:Zander671/random-scripts 2026-02-27 23:39:08 -08:00
Zander671 5c35e4dfdc Fix usbguard-notify.py 2026-02-27 23:38:53 -08:00
+3 -10
View File
@@ -11,10 +11,7 @@ DUNSTIFY_EXEC_NAME = shutil.which("dunstify")
open_notifications = {}
def parse_event_type_and_id(stream):
line = stream.readline()
if not line:
return None, True
def parse_event_type_and_id(line):
if not line.startswith("[device] "):
return None, False
event_type = re.findall("(?<=\\[device\\] )[a-zA-Z]+", line)
@@ -107,12 +104,8 @@ with Popen(
first_line = (
usbguard_proc.stdout.readline()
) # get rid of initial connection message
if not first_line:
sys.exit()
while True:
event_type_result, eof = parse_event_type_and_id(usbguard_proc.stdout)
if eof:
sys.exit()
for line in usbguard_proc.stdout:
event_type_result = parse_event_type_and_id(line)
if event_type_result is None:
continue
event_type, dev_id = event_type_result