One-liner #2: Enabling and Disabling Synaptic Touchpads

If you have notebook a with one of these large touchpads you might have come across this problem: You type something on the keyboard and suddenly the cursor jumps to a different location messing up your text (because you accidently touched the touchpad with your palm). To avoid this syndaemon allows you to automatically lock the touchpad when you type something on the keyboard. Desktop environments like XFCE make use of it. The downside of that is, that it can result in a frozen mouse pointer (for some milliseconds or seconds). Therefore I prefer to disable the touchpad manually by using a shortcut whenever I need that feature.

This post shows a one liner which allows you to disable your Synaptics touchpad temporarily. The same command allows you to enable it later again. By binding the command to a shortcut, you can easily toggle between an enabled or disabled touchpad.

For this I use the tool synclient, which should be already installed if you used a Synaptics touchpad under Linux. If it is not installed the name of the package should be something like xf86-input-synaptics. Once you have the tool, you can use this command:

$ synclient TouchpadOff="$(( ($(synclient -l | grep TouchpadOff | cut -d '=' -f 2) + 1) % 2 ))"

The command is quite simple. It runs the synclient -l which lists the current touchpad settings. It searches for TouchpadOff which is 1 if the touchpad is disabled or 0 if it is enabled. It takes that value and adds 1. It then takes the result modulo 2. That little tricks toggles the result from 0 to 1 or from 1 to 0. It then runs the synclient command again and passes TouchpadOff=0 or TouchpadOff=1 depending on what the value was before.
That's it! You can bind this command to a shortcut of your choice which allows you to easily disable or enable your touchpad on the fly.

Note: If the command doesn't seem to have any effect, make sure syndaemon is not running. syndaemon will interfere with synclient.

comments (0) - add comment

No comments so far, leave one?