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