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):
pbm@tauri ~ $ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ A4Tech USB Mouse id=10 [slave pointer (2)]
⎜ ↳ Macintosh mouse button emulation id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
[...]
Device that we need to use is A4Tech USB Mouse
with id=10
. Next we need to check properties of that device:
pbm@tauri ~ $ xinput list-props "A4Tech USB Mouse"
Device 'A4Tech USB Mouse':
Device Enabled (121): 1
[....]
To turn off device we need to change property Device Enabled
:
xinput set-prop DEV PROP STATE
xinput set-prop "A4Tech USB Mouse" "Device Enabled" 0
To turn it on:
xinput set-prop "A4Tech USB Mouse" "Device Enabled" 1
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:
pbm@tauri ~ $ cat /proc/bus/input/devices
I: Bus=0003 Vendor=046d Product=c312 Version=0110
N: Name="BTC USB Multimedia Keyboard"
P: Phys=usb-0000:00:1d.0-1.6/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0/input/input6
U: Uniq=
H: Handlers=kbd event3
B: EV=120013
B: KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=7
I: Bus=0003 Vendor=09da Product=000a Version=0110
N: Name="A4Tech USB Mouse"
P: Phys=usb-0000:00:1d.0-1.5/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.0/input/input8
U: Uniq=
H: Handlers=mouse1 event5
B: EV=17
B: KEY=ff0000 0 0 0 0
B: REL=343
B: MSC=10
[...]
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:
pbm@tauri ~ $ sudo actkbd -s -d /dev/input/event3
Keys: 29+41+42 //we need to press keys that will turn off mouse, 29+41+42 is Ctrl + Shift + `
When we know what are keys ids we need to put them to config file (/etc/actkbd.conf
):
29+41+42:::sudo -u pbm DISPLAY=:0 xinput set-prop "A4Tech USB Mouse" "Device Enabled" 0
To test it out we need to run actkbd
in daemon mode:
pbm@tauri ~ $ sudo actkbd -d /dev/input/event3 -D
In the same way we need to handle "turn on" event:
- Check handlers of mouse device
- Check key codes of left+right mouse button using
actkbd
- Put it to
actkbd.conf
- Run actkbd daemon to monitor mouse input device
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... ;)
Best Answer
On my ThinkPad X220T running GNOME 3 it's pretty easy to be typing along and accidentally bump the touchpad, causing some window other than the one you're typing into to be raised.
Ostensibly, the solution to this problem is to click your name in the upper right, then click "System Settings", then "Mouse and Touchpad", and then "Disable touchpad while typing" under as shown the screenshot at http://www.thinkwiki.org/wiki/Synaptics_TouchPad_driver_for_X .
This will cause
syndaemon
( http://linuxcommand.org/man_pages/syndaemon1.html ) to start up with the following options:Here's what the options mean:
Having syndaemon running with those options eliminates the original problem, but it absolutely kills my productivity because the
-t
option is not enabled:Without
-t
, as soon as I stop typing and try to move the pointer, I can't. I have to wait 2 full seconds before the pointer will move.Now, back at that "Mouse and Touchpad" interface, I do not see any way to configure which options are given to
syndaemon
and from what I can tell, the options are hard coded:http://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/mouse/gsd-mouse-manager.c?id=5ee48ce8aa66f6c4fdc4aa2c07bc03bdb83bcb65#n540
The solution is twofold. I can't abide
syndaemon
with its default options, so I leave "Disable touchpad while typing" unchecked. Then, to getsyndaemon
to start with the options I want, I rungnome-session-properties
to open the "Startup Applications Preferences" dialog. From there, I click Add, fill in a name (I called mine "0pdurbin-disable-touchpad-while-typing" so it would appear at the top), and a command, which for me is the following:Again, the major change is the addition of
-t
sosyndaemon
doesn't paralyze my pointer, but while I was in there I reduced the idle time to one second.I hope this helps someone because this was driving me crazy.
To avoid using a GUI tool like
gnome-session-properties
it looks like you could set up a file like this, which was created in my case:Incidentally, this seems to be a pretty complete list of applications that are autostarted, the ones listed in
gnome-session-properties
:find /etc/xdg/autostart /usr/share/autostart /usr/share/gdm/autostart/ /usr/share/gnome/autostart