multinput (Multiple mouse/keyboard input with xinput) | |
Sunday Dec 2 7:41:31 2012 | |
------------------------------ | |
I have got a dual head main desktop. I always thought it would be | |
nice to be able to use several keyboards and mice working | |
independently. Today I learnt how to easily configure multiple inpu | |
with xinput only to discover that my settings will always disappear | |
after every reboot or logout. | |
Well, the logical next step was to write an script to automatically | |
activate multiple input but since I also want to be able to | |
deactivate it at will I wrote two parts "start" and "stop". So the | |
usage goes: | |
$ multinput start | |
or | |
$ multinput stop | |
or | |
$ multinput restart | |
The script can either be run automatically at startup (anacron come | |
to mind) or manually. | |
Note: Be warned that this script is for personal use only. Feel fre | |
to adapt it to your own needs. I hope you like it and that it is | |
useful for you too. | |
Here it is: | |
#!/bin/sh | |
set -e | |
# Script for personal use, to set multiple mouse/keyboard input | |
# It uses xinput, so read its man page for more info. In order to | |
# list your devices type "xinput list" | |
MOUSE2="PIXART USB OPTICAL MOUSE" | |
KEYBOARD2="AT Translated Set 2 keyboard" | |
usage () | |
{ | |
echo "Type 'multinput start' to use multiple mice/keyboards." | |
echo "Type 'multinput stop' to stop using multiple mice/keyboards. | |
} | |
start () | |
{ | |
xinput create-master multinput | |
xinput reattach "$MOUSE2" "multinput pointer" | |
xinput reattach "$KEYBOARD2" "multinput keyboard" | |
} | |
# Leave devices floating | |
stop () | |
{ | |
xinput remove-master "multinput pointer" | |
} | |
if [ "$1" = "start" ] | |
then | |
start | |
exit | |
elif [ "$1" = "stop" ] | |
then | |
stop | |
exit | |
elif [ "$1" = "restart" ] | |
then | |
stop | |
start | |
exit | |
else | |
usage | |
fi | |