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 <i@rong.moe>
This commit is contained in:
Rongrong 2026-05-26 02:27:11 +08:00
parent 73ced3a7da
commit 8b134c31bb
No known key found for this signature in database
GPG Key ID: 1C2D45D45AB7FE94
1 changed files with 4 additions and 0 deletions

View File

@ -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)