Keyboard Shortcut To Toggle A Trackpad

I do not like laptop trackpads. They are not a good interface. A trackball would be more sensible and more like a mouse. I keep the trackpad on my Thinkpad T400 disabled and I use a small wireless mouse.

Despite my dislike, I decided I should have the trackpad available on demand. I wrote a script to toggle the trackpad. Opening a terminal window and running the script is a tad clunky. I prefer a clean desktop and that excluded a desktop shortcut. A *.desktop file in /usr/local/share/applications might suffice, but then I have to wade through the panel menu to launch the script.

A keyboard shortcut made sense.

I wanted to use the built-in Fn keys. There are three open Fn key combinations: F6, F10, and F11. I decided to use Fn+F6.

I added an /etc/acpi/event action and an /etc/acpi/ script, that launches /usr/local/bin/trackpad-toggle. I could have linked the action file directly to /usr/local/bin/trackpad-toggle, but I wanted consistency with the other /etc/acpi/event actions and scripts.

My trackpad-toggle script worked great in a terminal. The script always failed with the Fn+F6 shortcut. Adding some temporary logging output commands revealed why. With the shortcut the script gets run in a non-interactive shell, which means the xinput command failed. I used the xinput and synclient commands to determine the state of the trackpad and change the state. I added an interactive test to add when necessary an export DISPLAY=:0.0 snippet in the script to resolve the problem.

As I have been tinkering with Slackware 14.2 in preparation of updating to that release, I tested the new arrangement there too. The script again failed. This time I discovered for some reason the Fn+F6 shortcut is not recognized. I verified this with the acpi_listen command. I noticed the Fn+F11 shortcut was recognized. I modified the acpi files to use that shortcut.

The shortcut again failed. This time I paid closer attention to the output of the acpi_listen command. The event commands had changed.

Slackware 14.1:

event=ibm/hotkey HKEY 00000080 0000100b

Slackware 14.2:

event=button/fnf11 FF11 00000080 00000000 K

Next I discovered my trackpad-toggle script failed when run as root. The script ran fine as non-root. Yeah, I know what the priesthood chants about running X as root. Yadda yadda. Testing as root is legitimate. Not that I expect to need the trackpad as root, but the breakage is Just Another Example of Broken Software.

I rebooted to 14.1 to use Fn+F11 and successfully tested.

One thing in free/libre software is certain. Some developer somewhere will declare something “deprecated” and remove support without asking anybody. Something is always broken.

This is why the Year of the Linux Desktop never arrives. Linux operating systems are high maintenance. People just want to get things done.

Posted: Category: Usability Tagged: Slackware

Next: Broken Suspend to RAM in Slackware 14.2

Previous: Slackware NetworkManager and Firewall Conflict