I am an avid keyboard user, but I still need the mouse every now and then. To minimize the hand travel, I have the mouse located below my keyboard. (On a side note, using the mouse this way feels more natural to my hand.)
I am currently using unclutter to hide the pointer while I don’t use the mouse. Unfortunately, I am nudging it at times while typing, which causes the pointer to reappear. Sometimes this will move the pointer over another window, which in turn takes the focus away from my current window. (I am using sloppy focus, and changing this is not an option.)
I am now searching for a possibility to not only hide the pointer after a certain amount of idle time, but disable the mouse altogether. Clicking any mouse button or using the mouse wheel should then re-enable the mouse.
Best Answer
First thing that we need to accomplish is turning off mouse, but only in X. For this we could use
xinput
.We need to discover input devices that are connected to computer (to X server):
Device that we need to use is
A4Tech USB Mouse
withid=10
. Next we need to check properties of that device:To turn off device we need to change property
Device Enabled
:To turn it on:
Next thing is to do it automatically... ;) In this example we will be disabling mouse by keyboard shortcut and enable it by pressing left + right mouse button.
For this we could use actkbd - keyboard (but not only) shortcut daemon that works outside of X server.
First we need to create empty configuration file for actkbd:
touch /etc/actkbd.conf
. Next thing is to discover devices connected to computer:In this part most interesting for use are names and handlers of keyboard and mouse devices.
First we handle turning off mouse by keyboard shortcut, so we need to discover key ids:
When we know what are keys ids we need to put them to config file (
/etc/actkbd.conf
):To test it out we need to run
actkbd
in daemon mode:In the same way we need to handle "turn on" event:
actkbd
actkbd.conf
Running daemons could be realized as init script or autorun script in environment.
To automatically turning mouse off we could monitor input device (
cat /dev/input/event5
) and turn it off when there is no input...I hope that my short intro will help you... ;)