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 T=14 CURRENT_STATE=`xinput list-props $T | grep "Device Enabled" | egrep -o "[0-9]$"` if [ $CURRENT_STATE -eq "1" ]; then xinput --disable $T else xinput --enable $T fi
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.
It works perfectly thank you!
I only needs to adjust the ID of my touchpad (14 in your example).
To find the right one, I used: xinput list | grep -i touchpad
It gaves me 2 devices:
* PS/2 Synaptics TouchPad
* SYNA2393:00 06CB:7A13 Touchpad
I took the ID of the “SYNA” one and voilà!
Thanks, somehow I forgot to put that in when writing the article. I added it now.
Hi Mike, your post inspired me to make a tiny bit improved scripts that adapts to any device id in the machine. You awk just need to have gawk in your system (a gnu variant of the standard):
“`
#!/bin/bash
tp_id=$(xinput list | grep -i touchpad | awk ‘match($0, /\s+id=([0-9]+)/, a){print a[1]}’)
declare -i status=$(xinput list-props $tp_id | grep “Device Enabled” | egrep -o “[0-9]$”)
[[ $status == 1 ]] && action=disable || action=enable
echo “$action touchpad”
xinput $action $tp_id
“`
Best regards,
Claudio
* errata:
… machine. You just need to have gawk…
You can add:
zenity –notification –text “$action touchpad” >/dev/null 2>&1
after the echo line to display a nice notification in the desktop (of course have zenity installed)
and those dashed ( — ) are actually two dashes, your website transform them into a single (long) dash