Created
April 29, 2018 05:58
-
-
Save diego09310/5d4bddb9736e6506b20cd1528a72e200 to your computer and use it in GitHub Desktop.
Disable input devices in Linux
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
#!/bin/bash | |
# | |
# Shell script to disable (and reenable) the keyboard and the touchpad. | |
# I use it when cats are around and I can work with a wireless keyboard/mouse. | |
# To use it, execute "xinput list" to print the list of input devices and add | |
# the id and the master it belongs (number in parenthesis) to the id and | |
# master arrays. | |
# "./cat_mode.sh [on]" disables the configured devices | |
# "./cat_mode.sh off" (off or anything else) reenables the devices | |
# | |
id=(6 15 16) | |
master=(3 3 2) | |
idLength=${#id[@]} | |
if [ $# -eq 1 ]; then | |
input=$1 | |
else | |
input="on" | |
fi | |
if [ "$input" = "on" ]; then | |
for (( i=0; i<${idLength}; i++ )); | |
do | |
xinput float ${id[$i]} | |
done | |
else | |
for (( i=0; i<${idLength}; i++ )); | |
do | |
xinput reattach ${id[$i]} ${master[$i]} | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment