From 8b134c31bb0918877e66acbc344d3737fb61d8a7 Mon Sep 17 00:00:00 2001 From: Rongrong Date: Tue, 26 May 2026 02:27:11 +0800 Subject: [PATCH] rules: uinput: Fix device leakage While randomly messing around with rule components (I plan to add some new ones), I found this bug by screwing things up (shh...) Signed-off-by: Rongrong --- lib/logitech_receiver/diversion.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index 06d91150..579d6f9c 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -16,6 +16,7 @@ from __future__ import annotations +import contextlib import ctypes import logging import math @@ -330,6 +331,9 @@ def simulate_uinput(what, code, arg): logger.debug("uinput simulated input %s %s %s", what, code, arg) return True except Exception as e: + with contextlib.suppress(Exception): + udevice.close() + udevice = None logger.warning("uinput write failed: %s", e)