Last active
November 2, 2020 21:06
-
-
Save sgobotta/6713090510349f239d873076fc371ae1 to your computer and use it in GitHub Desktop.
Simple touchpad toggle for xfce environments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Configuration | |
# | |
# Press the super key => Keyboard => Shortcuts | |
# | |
# Use the next command, followed by your device name | |
# | |
# -- Zsh command line | |
# | |
# zsh -c "TOUCHPAD_MODEL='<your touchpad model>' /path/xfce-touchpad-toggle.sh" | |
# | |
# -- Bash command line | |
# | |
# bash -c "TOUCHPAD_MODEL='<your touchpad model>' /path/xfce-touchpad-toggle.sh" | |
# | |
# Search for your touchpad model using: | |
# | |
# xinput list | grep Touchpad | |
# | |
# Of course, you can alwaus just copy/paste your touchpad model in this | |
# script. | |
# | |
if [[ -z "$TOUCHPAD_MODEL" ]]; then | |
MESSAGE="Please add and export a <span font-family='Monospace' font-weight='normal' color='#999'>TOUCHPAD_MODEL</span> variable to your environment. \n\n➜ Use <span font-family='Monospace' font-weight='normal' color='#999'>xinput list | grep Touchpad</span>" | |
notify-send -t 10000 "Error" "$MESSAGE" --icon="error" | |
exit 1 | |
fi | |
TOUCHPAD_ID=$(echo $(xinput list --short "$TOUCHPAD_MODEL" | awk '{print $4}') | xargs -d "=" | awk '{print $2}') | |
IS_TOUCHPAD_ON=$(xinput list-props "$TOUCHPAD_ID" | grep "Device Enabled" | awk '{print $4}') | |
if [[ $IS_TOUCHPAD_ON -eq 0 ]]; then | |
xinput enable $TOUCHPAD_ID | |
notify-send -t 500 "Touchpad" "🖱️ State is On" --icon="info" | |
elif [[ $IS_TOUCHPAD_ON -eq 1 ]]; then | |
xinput disable $TOUCHPAD_ID | |
notify-send -t 500 "Touchpad" "🖱️ State is Off" --icon="info" | |
else | |
notify-send -t 500 "Touchpad" "State is super weird" --icon="error" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment