sane-input-handler: simplify the volume button controls; reduce vol-hold repeat count to 3
This commit is contained in:
parent
e6a8f5bae8
commit
ca57fd692f
|
@ -36,29 +36,11 @@ let
|
|||
in assert terminal -> events == []; events;
|
||||
|
||||
# trigger ${button}_hold_N every `holdTime` ms until ${button} is released
|
||||
recurseHold = button: { count ? 1, maxHolds ? 5, prefix ? "", holdTime ? 750, ... }@opts: lib.optionalAttrs (count <= maxHolds) {
|
||||
recurseHold = button: { count ? 1, maxHolds ? 3, holdTime ? 1000 }@opts: lib.optionalAttrs (count <= maxHolds) {
|
||||
"${button}_released".terminal = true; # end the hold -> back to root state
|
||||
timeout = {
|
||||
ms = holdTime;
|
||||
trigger = "${prefix}${button}_hold_${builtins.toString count}";
|
||||
} // (recurseHold button (opts // { count = count+1; }));
|
||||
};
|
||||
|
||||
# trigger volup_tap_N or voldown_tap_N on every tap.
|
||||
# if a volume button is held, then switch into `recurseHold`'s handling instead
|
||||
volumeActions = { count ? 1, maxTaps ? 5, prefix ? "", timeout ? 600, ... }@opts: lib.optionalAttrs (count != maxTaps) {
|
||||
volup_pressed = (recurseHold "volup" opts) // {
|
||||
volup_released = {
|
||||
trigger = "${prefix}volup_tap_${builtins.toString count}";
|
||||
timeout.ms = timeout;
|
||||
} // (volumeActions (opts // { count = count+1; }));
|
||||
};
|
||||
voldown_pressed = (recurseHold "voldown" opts) // {
|
||||
voldown_released = {
|
||||
trigger = "${prefix}voldown_tap_${builtins.toString count}";
|
||||
timeout.ms = timeout;
|
||||
} // (volumeActions (opts // { count = count+1; }));
|
||||
};
|
||||
ms = holdTime;
|
||||
trigger = "${button}_hold_${builtins.toString count}";
|
||||
timeout = recurseHold button (opts // { count = count+1; });
|
||||
};
|
||||
in
|
||||
{
|
||||
|
@ -163,12 +145,13 @@ in
|
|||
power_pressed.voldown_pressed.trigger = "power_and_voldown";
|
||||
|
||||
# map: volume taps and holds
|
||||
volup_pressed = (volumeActions {}).volup_pressed // {
|
||||
trigger = "volup_start";
|
||||
};
|
||||
voldown_pressed = (volumeActions {}).voldown_pressed // {
|
||||
trigger = "voldown_start";
|
||||
};
|
||||
volup_pressed.trigger = "volup_start";
|
||||
volup_pressed.volup_released.trigger = "volup_tap_1";
|
||||
volup_pressed.timeout = recurseHold "volup" {};
|
||||
|
||||
voldown_pressed.trigger = "voldown_start";
|
||||
voldown_pressed.voldown_released.trigger = "voldown_tap_1";
|
||||
voldown_pressed.timeout = recurseHold "voldown" {};
|
||||
});
|
||||
|
||||
sane.programs.sway.config.extra_lines = lib.mkIf cfg.enabled (
|
||||
|
|
Loading…
Reference in New Issue
Block a user