How to quickly enable/disable touchpad in Xubuntu 14.04 without installing other applications?
Solution 1
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
(namely 'show last used item' and 'inside button'),
- and adding two specific icons,
the launcher will always display the current status of the touchpad.
Also it is never a bad idea to assign shortcuts (Settings Manager - Keyboard - Application Shortcuts) to the two commands.
Solution 2
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.
Solution 3
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
Solution 4
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
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
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.
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?
-
TronicZomB over 7 yearsNote 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 over 7 yearsAlso, 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.
-
Admin over 6 yearsThis answer is better as
synclient TouchpadOff
etc doesn't need thexinput list
variable (which varies from system to system); but I find the launchers more Xfce-friendly; so I'll integrate this into my answer -
rbaleksandar over 4 yearsFunny, the commands (at least with synclient) don't work on my Dell XPS 15 9570. :D
-
Hastur over 4 yearsUnfortunately 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). -
cipricus over 3 years@Hastur - the
synclient
method stopped working in recent systems,xinput
method works. -
cipricus over 3 years
xinput disable ID
andxinput enable ID
also work. Notifications with icons can be added too: askubuntu.com/a/1318615/925128 -
Hastur over 3 years@cipricus Yep, I was trying to say so... ("but does not disable the touchpad"). I use
xinput
myself (in my script)... and you seem to confirm that it works for you too... :-)