Disable touchpad via button combination on Linux Laptop

This is another article in my continuing adventure in running Linux on my new Sager Laptop.

To recap, I bought a Sager brand laptop because it had the same specs as a System76 Unit but at about 60% the cost.   I figured if System76 can get a working desktop then the hardware should be pretty compatible.   Well, as I discovered, its an uphill battle.

I’m running popOS (System76’s os), basically an Ubuntu/Debian build without alot of the Ubuntu ‘phone home searching’ stuff.

One thing that was lacking was the Fn+F1 key to disable the trackpad.    Something that I kinda need since this unit comes with a nice, big trackpad.    And that trackpad can get in the way when I position my hands for typing long documents.

Out of the box, Fn+F1 is not recognized by the unit.   So here’s my workaround.

I started with a Terminal window to find the character input for fn+F1.    From a terminal use Ctrl+v then press the key combo and the get the input code.

This is the output when I hit Ctrl+v then Ctrl+F1

mike@pop-os:~$ ^[[1;5P

To test that, I used the following:

mike@pop-os:~$ bind '"\e[1;5P":"foobar"'

Pressing Ctrl+F1 gets me ‘foobar’ echoed to the display. So I know I have the right key code.

Now to identify the touchpad’s identifier in xinput.   This number will be different for different laptops. In this example, my laptop’s Synaptic touchpad is at number 14.

mike@pop-os:~$ xinput list | grep -i touchpad
⎜   ↳ SYNA1202:00 06CB:CD65 Touchpad          	id=14	[slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad              	id=18	[slave  pointer  (2)]

Next, I lifted a script that I found that toggles the touchpad via the command line. I saved this on my system:

#! /bin/bash
CURRENT_STATE=`xinput list-props $T | grep "Device Enabled" | egrep -o "[0-9]$"`
if [ $CURRENT_STATE -eq "1" ]; then
    xinput --disable $T
    xinput --enable $T

I saved that to /opt/scripts/touchpadtoggle.sh and made it executable with ‘chmod +x’.

I tested the toggle script with:

mike@pop-os:~$ bind '"\e[1;5P":"/opt/scripts/touchpadtoggle.sh\n"'

Note that the ‘/n’ at the end sends a new line to execute the script.
Since the key combo does work and the touchpad toggles like I want, I can setup the key bind on each login by adding that bind line to ~/.inputrc

Or, you can add it to the Desktop by using Keyboard Shortcuts:

Reboot to test and now I have a usable touchpad toggle via key combo.

Tagged , , . Bookmark the permalink.

2 Responses to Disable touchpad via button combination on Linux Laptop

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
15 × 6 =