From 309797fe2315a3e13eeaeadd93e860d91e1ef5ab Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 24 May 2024 04:29:34 +0000 Subject: [PATCH] sane-input-handler: fix unrecoverable terminal state bonsai is prone to miss inputs during high CPU load. --- hosts/common/programs/sane-input-handler/default.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hosts/common/programs/sane-input-handler/default.nix b/hosts/common/programs/sane-input-handler/default.nix index 25729c34..d9b37361 100644 --- a/hosts/common/programs/sane-input-handler/default.nix +++ b/hosts/common/programs/sane-input-handler/default.nix @@ -36,11 +36,14 @@ let in assert terminal -> events == []; events; # trigger ${button}_hold_N every `holdTime` ms until ${button} is released - recurseHold = button: { count ? 1, maxHolds ? 3, holdTime ? 1000 }@opts: lib.optionalAttrs (count <= maxHolds) { - "${button}_released".terminal = true; # end the hold -> back to root state - ms = holdTime; + recurseHold = button: { count ? 1, maxHolds ? 3, holdTime ? 1000 }@opts: { trigger = "${button}_hold_${builtins.toString count}"; + ms = holdTime; + } // lib.optionalAttrs (count < maxHolds) { timeout = recurseHold button (opts // { count = count+1; }); + # end the hold -> back to root state + # take care to omit this on the last hold though, so that there's always a strictly delay-driven path back to root + "${button}_released".terminal = true; }; in {