First you need to find the name of your touchpad in the xinput list:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Razer Razer Imperator id=10 [slave pointer (2)]
⎜ ↳ Razer Razer Imperator id=11 [slave pointer (2)]
⎜ ↳ PS/2 Mouse id=13 [slave pointer (2)]
⎜ ↳ AlpsPS/2 ALPS GlidePoint id=14 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Sony Vaio Keys id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ USB 2.0 Camera id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
So in my case the touchpad is most likely: PS/2 Mouse on id 13.
You can easily identify if the device is “on” (enabled):
$ xinput list-props “PS/2 Mouse”
Device ‘PS/2 Mouse’:
Device Enabled (144): 1
Coordinate Transformation Matrix (146): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (267): 0
Device Accel Constant Deceleration (268): 1.000000
Device Accel Adaptive Deceleration (269): 1.000000
Device Accel Velocity Scaling (270): 10.000000
Evdev Axis Inversion (271): 0, 0
Evdev Axes Swap (273): 0
Axis Labels (274): “Rel X” (154), “Rel Y” (155)
Button Labels (275): “Button Left” (147), “Button Middle” (148), “Button Right” (149), “Button Wheel Up” (150), “Button Wheel Down” (151)
Evdev Middle Button Emulation (276): 0
Evdev Middle Button Timeout (277): 50
Evdev Wheel Emulation (278): 0
Evdev Wheel Emulation Axes (279): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (280): 10
Evdev Wheel Emulation Timeout (281): 200
Evdev Wheel Emulation Button (282): 4
Evdev Drag Lock Buttons (283): 0
Now create yourself a little file (eg: “touchpad”):
# toggle synaptic touchpad on/off
SYNSTATE=$(xinput list-props “PS/2 Mouse” | grep Enabled | grep -Eo ‘.$’)
if [ $SYNSTATE = 0 ]; then xinput set-int-prop “PS/2 Mouse” “Device Enabled” 8 1
else xinput set-int-prop “PS/2 Mouse” “Device Enabled” 8 0; fi
dengar@dengar-vaio:/usr/bin$ $ xinput list-props “PS/2 Mouse”
This should sort you out. Don’t forget to change the name of your actual device, remember mine is “PS/2 Mouse”
Next you need to make the file executable:
sudo chmod +x touchpad
Now, to have that file available from the command line, simply copy it to /usr/bin.