From 5c35e4dfdcbcbaa5f75bd70d22be0938f98aba84 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 27 Feb 2026 23:38:39 -0800 Subject: [PATCH] Fix usbguard-notify.py --- usbguard-notify.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/usbguard-notify.py b/usbguard-notify.py index 93b93ed..5f0f319 100755 --- a/usbguard-notify.py +++ b/usbguard-notify.py @@ -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