From 20f70dd27ac0bb7ac4611d50bede3aa20a43b93c Mon Sep 17 00:00:00 2001 From: rope Date: Tue, 19 May 2026 17:31:53 +0100 Subject: [PATCH] Fix dwt ignoring modifiers like shift, alt etc. --- hosts/FredOS-Macbook.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hosts/FredOS-Macbook.nix b/hosts/FredOS-Macbook.nix index 2fe7561..b27fed2 100644 --- a/hosts/FredOS-Macbook.nix +++ b/hosts/FredOS-Macbook.nix @@ -49,6 +49,8 @@ import glob, os, select, struct, time EVENT_SIZE = struct.calcsize("llHHi") EV_KEY = 0x01 DWT_TIMEOUT = 0.3 +# Modifier keycodes — don't inhibit touchpad for these +MODIFIERS = {42, 54, 29, 97, 56, 100, 125, 126} # L/R Shift, Ctrl, Alt, Super def find_event(name): for p in sorted(glob.glob("/sys/class/input/event*/device/name")): @@ -75,8 +77,8 @@ def main(): if r: data = os.read(f.fileno(), EVENT_SIZE * 64) for off in range(0, len(data) - EVENT_SIZE + 1, EVENT_SIZE): - _, _, typ, _, val = struct.unpack("llHHi", data[off:off + EVENT_SIZE]) - if typ == EV_KEY and val: + _, _, typ, code, val = struct.unpack("llHHi", data[off:off + EVENT_SIZE]) + if typ == EV_KEY and val and code not in MODIFIERS: last_key = time.monotonic() if not active: open(inhibit, "w").write("1")