Skip to content

Instantly share code, notes, and snippets.

@haarp
Created March 8, 2024 10:16
Show Gist options
  • Save haarp/07ed9e7abc299b08a32a2f9c0310ae96 to your computer and use it in GitHub Desktop.
Save haarp/07ed9e7abc299b08a32a2f9c0310ae96 to your computer and use it in GitHub Desktop.
toggle-touchpad
#!/bin/bash
# Toggle libinput touchpad state with each execution
touchpad=$(xinput list --name-only | grep -i touchpad)
props=$(xinput list-props "$touchpad")
enabled=$(awk '/Device Enabled \(...\)/{print $4}' <<< "$props")
tapping=$(awk '/libinput Tapping Enabled \(...\)/{print $5}' <<< "$props")
if [[ $enabled -eq 1 ]]; then
if [[ $tapping -eq 1 ]]; then
notify-send -i input-touchpad "$touchpad" "** tapping/scrolling OFF **"
xinput set-prop "$touchpad" "libinput Tapping Enabled" 0
xinput set-prop "$touchpad" "libinput Scroll Method Enabled" 0 0 0
else
notify-send -i input-touchpad "$touchpad" "** OFF **"
xinput set-prop "$touchpad" "Device Enabled" 0
fi
else
notify-send -i input-touchpad "$touchpad" " ** ON **"
xinput set-prop "$touchpad" "Device Enabled" 1
xinput set-prop "$touchpad" "libinput Tapping Enabled" 1
xinput set-prop "$touchpad" "libinput Scroll Method Enabled" 1 0 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment