Skip to content

Instantly share code, notes, and snippets.

@flipsi
Created May 21, 2015 11:51
Show Gist options
  • Save flipsi/eb0f1eb5e963233d5f38 to your computer and use it in GitHub Desktop.
Save flipsi/eb0f1eb5e963233d5f38 to your computer and use it in GitHub Desktop.
Toggle Input Device Enabled (Like Touchpads)
#!/bin/bash
# Author: Philipp Moers <soziflip gmail com>
# This script disables an xinput device if it is enabled and vice versa
# adjust this to your needs
DEVICE="PS/2 Logitech Wheel Mouse"
# ---------------------------------------------------------------------
# get old state
STATE=$(xinput --list-props "$DEVICE" | grep "Device Enabled" | cut -f3)
# calculate next state
if [ $STATE -eq 1 ]; then
NEXTSTATE=0
else
NEXTSTATE=1
fi
# set next state
xinput --set-prop "$DEVICE" "Device Enabled" $NEXTSTATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment