There are at least two methods (that I know of) you could try.
synclient
If your laptop is equipped with a Synaptics (or ALPS) touchpad you can indeed use synclient as already mentioned by Shutupsquare. I'm running Ubuntu 14.04 and on my machine it was installed by default.
Test if synclient is installed: synclient -V (it should report the version number)
Turn touchpad ON: synclient TouchpadOff=0
Turn touchpad OFF: synclient TouchpadOff=1
I have not tested this myself, but if your goal is to not move the mouse when your arms are resting on the touch pad, this might help.
Turn palm detection ON: synclient PalmDetect=1
Turn palm detection OFF: synclient PalmDetect=0
In general you can configure any property of your Synaptics touchpad by synclient property=value. Where the property is one of the available properties shown by synclient -l
When setting properties through either xinput or synclient the properties are not set to the other tool. They are also not set in unity-control-center.
synclient and xinput will not work if you are using gnome (or unity, cinnamon) environment, because it will override settings, so if you want synclient or xinput to take over these settings, you should disable that first:
install dconf-editor if not installed:
apt-get install dconf-editor
run dconf-editor
dconf-editor
open the directory /org/gnome/settings-daemon/plugins/mouse/ or /org/cinnamon/settings-daemon/plugins/mouse/, and unclick the checkbox for active.
I wrote a python piece of code (now updated from python2 to python3) so that you can use the xinput technique without doing all the manual work. Copyleft, AS-IS, no warranty, use at your own risk. Works great for me: and if you are using gnome, just map it to a key shortcut like CtrlShiftT.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''Program to toggle Touchpad Enable to Disable or vice-versa.'''
from subprocess import check_output
import re
def current_id():
""" Search through the output of xinput and find the line that has the
word Touchpad. At that point, I believe we can find the ID of that device.
"""
props = check_output(["xinput"]).decode("utf-8").splitlines()
match = [line for line in props if "Touchpad" in line]
assert len(match) == 1, "Problem finding Touchpad string! %s" % match
pat = re.match(r"(.*)id=(\d+)", match[0])
assert pat, "No matching ID found!"
return int(pat.group(2))
def current_status(tpad_id):
"""Find the current Device ID
- it has to have the word Touchpad in the line."""
props = check_output(
['xinput','list-props',str(tpad_id)]).decode("utf-8").splitlines()
match = [line for line in props if "Device Enabled" in line]
assert len(match) == 1, "Can't find the status of device #%d" % tpad_id
pat = re.match(r"(.*):\s*(\d+)", match[0])
assert pat, "No matching status found!"
return int(pat.group(2))
def flop(tpad_id, status):
"""Change the value of status, and call xinput to reverse that status."""
if status == 0:
status = 1
else:
status = 0
print("Changing Device #",tpad_id," Device Enabled to ",status)
props = check_output(['xinput',
'set-prop',
str(tpad_id),
'Device Enabled',
str(status)])
def main():
"""Get curent device id and status, and flop status value."""
tpad = current_id()
stat = current_status(tpad)
flop(tpad, stat)
main()
On Gnome, my function key to toggle the touchpad was not working for some reason, so I made a script using gsettings.
Advantage: not vendor-specific
Disadvantage: on Gnome, the touchpad clicks (not tap) are still handled for some reason, whereas the xinput solution completely deactivates the touchpad as expected. If like me, your only problem is that you are inadvertently moving the cursor while typing, though, that will be enough.
toggle_touchpad_gsettings.py
#!/usr/bin/python3.6
import sys
import subprocess
gsettings_schema, gsettings_key = "org.gnome.desktop.peripherals.touchpad", "send-events"
def get_touchpad_send_events():
send_events_value = subprocess.check_output(["gsettings", "get", gsettings_schema, gsettings_key])
return send_events_value.strip()
def toggle_touchpad():
# string returned from get is a repr including quotes,
# but string sent with set does not need to have quotes
if get_touchpad_send_events() == b"'enabled'":
newval = 'disabled'
else:
newval = 'enabled'
subprocess.Popen(["gsettings", "set", gsettings_schema, gsettings_key, newval])
print(f"Set {gsettings_schema}:{gsettings_key} to {newval}")
def main():
toggle_touchpad()
if __name__ == '__main__':
main()
It should also work on Unity, but I haven't tested.
To turn off touch pad:
To turn it back on:
There are at least two methods (that I know of) you could try.
synclient
If your laptop is equipped with a Synaptics (or ALPS) touchpad you can indeed use
synclient
as already mentioned by Shutupsquare. I'm running Ubuntu 14.04 and on my machine it was installed by default.Test if synclient is installed:
synclient -V
(it should report the version number)Turn touchpad ON:
synclient TouchpadOff=0
Turn touchpad OFF:
synclient TouchpadOff=1
I have not tested this myself, but if your goal is to not move the mouse when your arms are resting on the touch pad, this might help.
Turn palm detection ON:
synclient PalmDetect=1
Turn palm detection OFF:
synclient PalmDetect=0
In general you can configure any property of your Synaptics touchpad by
synclient property=value
. Where the property is one of the available properties shown bysynclient -l
Links for further reading
ubuntu - comminity help wiki - SynapticsTouchpad
archlinux - wiki - Touchpad Synaptics
ask ubuntu - How do I make my synclient settings stick? - Ubuntu
xinput
If you do not want or cannot use synclient, you could also use
xinput
. The procedure is somewhat similar.list all xinput devices:
xinput
Part of the ouput could look like this:
It this particular case my touchpad has id=17 and its full name is "ETPS/2 Elantech Touchpad".
The command to set a property is
xinput set-prop
. The property to enable or disable the touchpad isDevice Enabled
, so to enable or disable it type:Turn touchpad ON:
xinput set-prop <id> "Device Enabled" 1
(where<id>
is your device id, in my case 17)Turn touchpad OFF:
xinput set-prop <id> "Device Enabled" 0
Turn palm detection ON:
xinput set-prop <id> "Palm Detection" 1
Turn palm detection OFF:
xinput set-prop <id> "Palm Detection" 0
To query available properties:
xinput list-props <id>
ORxinput list-props <full-name>
, this should be quite similair tosynclient -l
.Links for further reading
ubuntu - wiki - input
NOTE
When setting properties through either
xinput
orsynclient
the properties are not set to the other tool. They are also not set in unity-control-center.synclient
andxinput
will not work if you are using gnome (or unity, cinnamon) environment, because it will override settings, so if you wantsynclient
orxinput
to take over these settings, you should disable that first:install
dconf-editor
if not installed:run
dconf-editor
open the directory
/org/gnome/settings-daemon/plugins/mouse/
or/org/cinnamon/settings-daemon/plugins/mouse/
, and unclick the checkbox foractive
.logout
orreboot
This should make
synclient
orxinput
work.I wrote a python piece of code (now updated from python2 to python3) so that you can use the
xinput
technique without doing all the manual work. Copyleft, AS-IS, no warranty, use at your own risk. Works great for me: and if you are using gnome, just map it to a key shortcut like CtrlShiftT.List your input devices:
In my case I have this list:
Disable your touchpad by passing the ID
Disable any touchpad in a single command, good for a script.
On Gnome, my function key to toggle the touchpad was not working for some reason, so I made a script using gsettings.
xinput
solution completely deactivates the touchpad as expected. If like me, your only problem is that you are inadvertently moving the cursor while typing, though, that will be enough.toggle_touchpad_gsettings.py
It should also work on Unity, but I haven't tested.