feat: Add Touchpad toggle/on/off support (#5353)
* feat: add touchpad toggle keybinding and script Binds XF86TouchpadToggle/On/Off to a new leenium-toggle-touchpad script that enables/disables the touchpad via hyprctl and shows OSD feedback. * fix: make XF86TouchpadOn/Off enforce state instead of toggling Add on/off/toggle argument support to omarchy-toggle-touchpad. XF86TouchpadOn now always enables and XF86TouchpadOff always disables, so firmware that emits separate On/Off keysyms behaves correctly regardless of current state. XF86TouchpadToggle retains the invert behavior. * feat: add touchpad toggle to menu and persist state as hyprland config - Show touchpad option in toggle menu only when a touchpad/trackpad device is detected - Replace /tmp state file with a persistent hyprland device config at ~/.local/state/omarchy/toggles/hypr/touchpad-disabled.conf * fix: avoid unsafe && || toggle logic for Touchpad state Replace `[[ -f $STATE_CONF ]] && enable || disable` with an explicit if/else. The previous logic was not a true ternary: if `enable` failed (e.g. OSD command error), `disable` would run unintentionally, causing unreliable toggle behavior.
This commit is contained in:
+8
-1
@@ -168,7 +168,13 @@ show_share_menu() {
|
||||
}
|
||||
|
||||
show_toggle_menu() {
|
||||
case $(menu "Toggle" " Screensaver\n Nightlight\n Idle Lock\n Top Bar\n Workspace Layout\n Window Gaps\n 1-Window Ratio\n Monitor Scaling\n Laptop Display") in
|
||||
local options=" Screensaver\n Nightlight\n Idle Lock\n Top Bar\n Workspace Layout\n Window Gaps\n 1-Window Ratio\n Monitor Scaling\n Laptop Display"
|
||||
|
||||
if hyprctl devices -j 2>/dev/null | jq -e '[.mice[] | select(.name | test("touchpad|trackpad"; "i"))] | length > 0' >/dev/null; then
|
||||
options="$options\n Touchpad"
|
||||
fi
|
||||
|
||||
case $(menu "Toggle" "$options") in
|
||||
|
||||
*Screensaver*) omarchy-toggle-screensaver ;;
|
||||
*Nightlight*) omarchy-toggle-nightlight ;;
|
||||
@@ -179,6 +185,7 @@ show_toggle_menu() {
|
||||
*Gaps*) omarchy-hyprland-window-gaps-toggle ;;
|
||||
*Scaling*) omarchy-hyprland-monitor-scaling-cycle ;;
|
||||
*Laptop*) omarchy-hyprland-monitor-internal-toggle ;;
|
||||
*Touchpad*) omarchy-toggle-touchpad ;;
|
||||
*) back_to show_trigger_menu ;;
|
||||
esac
|
||||
}
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
STATE_CONF="$HOME/.local/state/omarchy/toggles/hypr/touchpad-disabled.conf"
|
||||
osdclient="swayosd-client --monitor $(omarchy-hyprland-monitor-focused)"
|
||||
|
||||
device="$(hyprctl devices -j | jq -r '[.mice[] | .name | select(test("touchpad|trackpad"; "i"))] | first // empty')"
|
||||
|
||||
if [[ -z $device ]]; then
|
||||
echo "No touchpad device found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
enable() {
|
||||
hyprctl keyword "device[$device]:enabled" true >/dev/null
|
||||
rm -f "$STATE_CONF"
|
||||
$osdclient --custom-icon input-touchpad-symbolic --custom-message "Enabled"
|
||||
}
|
||||
|
||||
disable() {
|
||||
hyprctl keyword "device[$device]:enabled" false >/dev/null
|
||||
mkdir -p "$(dirname "$STATE_CONF")"
|
||||
printf 'device {\n name = %s\n enabled = false\n}\n' "$device" > "$STATE_CONF"
|
||||
$osdclient --custom-icon touchpad-disabled-symbolic --custom-message "Disabled"
|
||||
}
|
||||
|
||||
case "${1:-toggle}" in
|
||||
on) enable ;;
|
||||
off) disable ;;
|
||||
toggle)
|
||||
if [[ -f $STATE_CONF ]]; then
|
||||
enable || {
|
||||
echo "enable failed" >&2
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
disable || {
|
||||
echo "disable failed" >&2
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -11,6 +11,9 @@ bindeld = ,XF86MonBrightnessDown, Brightness down, exec, omarchy-brightness-disp
|
||||
bindeld = ,XF86KbdBrightnessUp, Keyboard brightness up, exec, omarchy-brightness-keyboard up
|
||||
bindeld = ,XF86KbdBrightnessDown, Keyboard brightness down, exec, omarchy-brightness-keyboard down
|
||||
bindld = ,XF86KbdLightOnOff, Keyboard backlight cycle, exec, omarchy-brightness-keyboard cycle
|
||||
bindld = ,XF86TouchpadToggle, Toggle touchpad, exec, omarchy-toggle-touchpad
|
||||
bindld = ,XF86TouchpadOn, Enable touchpad, exec, omarchy-toggle-touchpad on
|
||||
bindld = ,XF86TouchpadOff, Disable touchpad, exec, omarchy-toggle-touchpad off
|
||||
|
||||
# Precise 1% multimedia adjustments with Alt modifier
|
||||
bindeld = ALT, XF86AudioRaiseVolume, Volume up precise, exec, $osdclient --output-volume +1
|
||||
|
||||
Reference in New Issue
Block a user