22

In Xubuntu 14.04. accessing the settings to disable and enable the touchpad are a bit hidden - in Settings-Mouse and Touchpad, and once there, there are a few other clicks needed.

enter image description here

I have tried by installing the panel application touchpad-indicator - but that seemed buggy in Xfce maybe due to conflicts with the Xfce settings...

Is there a quick and safe method to enable/disable touchpad?

4 Answers 4

31

That can be easily done with these two commands (inspired by a different answer):

Disable:

synclient TouchpadOff=1

Enable:

synclient TouchpadOff=0

My initial answer was to use

xinput set-prop 15 "Device Enabled" 0

and

xinput set-prop 15 "Device Enabled" 1

where the id number may be other than 15: it can be be found by running

xinput list

I found about these commands in this answer under a question on how to disable the touchpad.


The commands can be added into launchers.

I prefer creating .desktop files (in usr/share/applications or in .local/share/applications) for the two commands to be run easily with a launcher like Whisker Menu, Synapse, etc


Also:

  • by adding them into a single launcher,

  • setting advanced properties like in the image below

enter image description here

(namely 'show last used item' and 'inside button'),

  • and adding two specific icons,

the launcher will always display the current status of the touchpad.

enter image description here


Also it is never a bad idea to assign shortcuts (Settings Manager - Keyboard - Application Shortcuts) to the two commands.

1
  • Funny, the commands (at least with synclient) don't work on my Dell XPS 15 9570. :D Nov 2, 2019 at 11:27
13

You also can use synclient, like in this answer.

To turn off touchpad:

synclient TouchpadOff=1

To turn on:

synclient TouchpadOff=0

I think this is more convenient way. You don't need to know device id.

So my solution is to create bash script ~/toggle-touchpad.sh:

#!/bin/bash
if synclient | grep --quiet 'TouchpadOff             = 0'; then
  synclient TouchpadOff=1
  notify-send Touchpad Disabled
else
  synclient TouchpadOff=0
  notify-send Touchpad Enabled
fi

Modify file permission:

sudo chmod +x ./toggle-touchpad.sh

Next goto Settings-Keyboard-Application Shortcuts and add new shortcut. Enter path to the script (/home/your_username/toggle-touchpad.sh - for example). Specify shortcut (Fn+F9 in my case).

Done. Now you can toggle touchpad and you will get notification.

6
  • Note to others, the spaces in the if statement are all necessary for this script to run correctly. Also, I think it should be sudo chmod +x ~/toggle-touchpad.sh
    – TronicZomB
    Dec 31, 2016 at 19:06
  • Also, if you like clean files/file structure you could always name the script ".toggle-touchpad.sh" (with a dot "." out front) so that it is a hidden file but will still run just fine.
    – TronicZomB
    Dec 31, 2016 at 19:08
  • This answer is better as synclient TouchpadOff etc doesn't need the xinput list variable (which varies from system to system); but I find the launchers more Xfce-friendly; so I'll integrate this into my answer
    – user47206
    Oct 5, 2017 at 13:25
  • Unfortunately under kubuntu 18.04LTS it doesn't work. It changes the status number from 2 (the default) to 0 and 1... but do not disable the touchpad. Using xinput --disable 12 where 12 is the number of the device it works. Nice use of notify send (+1).
    – Hastur
    Mar 10, 2020 at 12:15
  • @Hastur - the synclient method stopped working in recent systems, xinput method works.
    – cipricus
    Feb 23, 2021 at 11:34
10

The non-launcher version:

#!/bin/bash

# toggle state of synaptics touchpad

tpid=`xinput list | grep SynPS | sed 's/.*id\=\([0-9]\+\).*/\1/g'`

declare -i status
status=`xinput list-props ${tpid} | grep Device\ Enabled | sed -e 's/.*\:[ \t]\+//g'`

if [ 0 -eq ${status} ] ; then
    xinput enable ${tpid}
else
    xinput disable ${tpid}
fi
3

I have used @cipricus and @Demeter answers, but without using synclient, i thought that would be good to share:

#!/bin/sh

TOGGLE=$HOME/.toggle
TOUCHPAD_ID=$(xinput list | grep "Touchpad" | grep -Eow '[0-9]{2}')

if [ ! -e $TOGGLE ]; then
   touch $TOGGLE
   xinput set-prop $TOUCHPAD_ID "Device Enabled" 0
else
   rm $TOGGLE
   xinput set-prop $TOUCHPAD_ID "Device Enabled" 1
fi
1

You must log in to answer this question.