Touchpad Toggle With F6 on Zorin OS 16

Hi. I just turn off the touchpad instead of totally disabling it. For that I have F6 button on my laptop to turn off the touchpad. However, upon restart, I again have to press F6 in order to turn off the touchpad and use my wireless optical mouse. How can I make this pressing of F6 programmatically on Zorin upon restart?

A possible solution would be to install a program like xdotool, create a script, and add that script to start up applications.

  1. open a terminal window
  2. enter "sudo apt-get install xdotool"
  3. install this program
  4. browse to a location where you would like to store your script, this can be essentially anywhere on your computer. For this example I will just be putting it in documents.
  5. enter "cd ~/Documents"
  6. enter "nano"
  7. Once in this file you can paste this script which will simple press the f6 key when ran:

xdotool key XF86TouchpadToggle

  1. control+x to exit nano, press y, then enter to output to the file.
  2. now we must make this file executable so the computer will be able to run the script, run in the the same terminal window "chmod +x" this makes the script executable.
  3. now in the zorin menu look for startup applications and launch it.
  4. in this window click add to make a new startup entry.
  5. enter this information
    Name: touchpad
    Command: ./~/Documents/
    Comment: Turns off touchpad on boot.
  6. click add and now this script should execute on boot and cause for f6 to be clicked which should turn off your touchpad.

Not working. When I type in "sudo xdotool key F6" I am getting like this(some strange characters...). See the image below.Screenshot from 2021-08-18 19-33-31

Do you use the function key to turn off your touchpad?
FN+F6? because that would change the script.

Plus, when using it in that way in terminal it's doing the key press in the terminal window rather than just an input on say the desktop. try running the script by just clicking on it and executing it normally rather than through terminal and see what that does for you.

I do have the "Fn" key. But I just press on F6(a touchpad emoticon is on the key) to turn off the touchpad.

And nothing happens when just executing the file.

You likely have function lock turned on then and the fn key is being recognized as pressed due to fn key being linked to the keyboard micro controller. Currently trying to see how to induce an fn key press using xdotool, have to find a way to see the keyboard output to induce this keystroke.

xmodmap -pke | grep TouchpadToggle
this will list the key code needed for the toggle, use this code rather than F6 in the script and it should work!

even simpler just run:
xdotool key XF86TouchpadToggle

Follow my previous guide but just use this in the script rather than F6. I edited it to reflect this change.

Running xdotool key XF86TouchpadToggle is entirely disabling and enabling the touchpad entirely instead of toggling. When I use that command I can't use the F6 to turn on/off.

In windows 10 this used to work fine. The system used to remember whether before the shutdown touchpad is on/off. So when I used to start the system the next time, touchpad would be in an off state. I used to press F6 when I had to use the touchpad.

I did replace F6 in the script with the code I got from xdotool. It didn't work.

Just tested this in my laptop and this is now what I'm experiencing. When using the command the F6 key still operates as expected and is able to toggle the touchpad as per usual. The command is just sending the system the exact message that your keyboard would if you were to press the key so I'm not sure why you'd be having this issue.

Is it possible to know which code is being sent when I press the F6?

xmodmap -pke | grep TouchpadToggle
this will give you a key id, you can try that id number rather than XF86TouchpadToggle

It gives me 199. When I use xdotool key 199 the touchpad is being disabled. Toggling doesn't work with F6 until I execute xdotool key 199 again.

That's really interesting. One thing funnily enough is you could do a keyboard shortcut to have that script execute on an F6 press

Oh. I see. How do I do that?

Settings, Keyboard shortcuts, add, for the command do a path to the script file, for the key just add F6 as a key.


Or can I use another key combination to toggle the touchpad instead of F6?

Yes, any key combination you'd like for toggling the touchpad using what i just said, just use the key combo you'd like instead of F6.

How do I create a key combination? Do I have to install some software?