ThinkPad Function-Key Mapping to Toggle Touchpad in Ubuntu 18.04
As a ThinkPad enthusiast, I’m a fan of using the TrackPoint for mouse navigation. I prefer to disable the touchpad altogether, just to avoid accidental clicks caused by my palms.
I recently installed Ubuntu 18.04 on my X1 Carbon (5th-Gen) and couldn’t find a straightfoward way to toggle the touchpad on and off with a keyboard shortcut. After some Googling, I managed to map one of my unused function-keys to toggle the touchpad.
These are the steps it took to get things working!
Define an ACPI event to run a script on keypress
Function-key events can be found by opening the terminal and running acpi_listen
. When a key is pressed, its corresponding event name will be displayed:
Using the event name, we can define an ACPI event by creating a new file in /etc/acpi/events/
:
/etc/acpi/events/ibm-touchpad
:
event
is the name of our desired function-key event. action
is the script we will create in the next step.
Create a custom script to toggle the touchpad
The script will use xinput
to find the status of the touchpad and toggle it accordingly. For xinput
to work, we need to specify the XAUTHORITY
environment-variable in the script.
We can get this by running echo $XAUTHORITY
:
Now, we can create our new script:
/etc/acpi/ibm-touchpad.sh
:
Then, we make the script executable (Note: You may need to sudo
this command.):
Finally, restart the system and log back in. If things are set up properly, the function-key should toggle the touchpad!
Conclusion
The following links were extremely helpful in getting this working:
- AskUbuntu post with enable/disable touchpad script
- UbuntuWiki article on
xinput
- ThinkWiki article on configuring ACPI
Questions? Suggestions? Corrections? Leave me a comment. Cheers!