Skip to content

Instantly share code, notes, and snippets.

@kd35a
Created April 28, 2012 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kd35a/2522153 to your computer and use it in GitHub Desktop.
Save kd35a/2522153 to your computer and use it in GitHub Desktop.
Script than enables or disables a device
#!/bin/bash
#--------------------------------------------------------------------
# Authur: Fredrik "kd35a" Strandin <fredrik [at] strandin (dot) name>
# License: WTFPL (Do What The Fuck You Want To Public License)
# ---
# Disable or enables a specific input device.
# Use 'xinput --list' to see which device you want to enable/disable.
#--------------------------------------------------------------------
# Configuration
# Which device to enable or disable, see 'xinput --list'.
DEV=$(xinput --list --id-only "AT Translated Set 2 keyboard")
# End of configuration
if [ ! "$#" -eq 1 ]; then
echo "Error, wrong number of parameters. Usage: '$0 < enable | disable >'"
exit 1;
fi
if [ "$1" == "enable" ]; then
DISPLAY=:0.0 xinput set-int-prop $DEV "Device Enabled" 8 1;
exit 0;
fi
if [ "$1" == "disable" ]; then
DISPLAY=:0.0 xinput set-int-prop $DEV "Device Enabled" 8 0;
exit 0;
fi
echo "Lol, only 'enable' and 'disable' are valid arguments";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment