Lubuntu18.04: how to save touchpad settings?

@azdays15: Thank you very much for this detailed instruction :smile:
Weird stuff, but I think I can manage after will have you will have answered these questions, please:

*** 1 ***
Did I understand you correctly that the whole thing is for LXDE?
Because your final remark

That’s what I would start with if I was running LXQt.

confuses me.
LXDE would be fine because I am using Lubuntu 18.04

*** 2 ***

What I did was edit the keyboard shortcut .xml file and add this to it:

Where do I find this file?

Please note, I know a lot but of this lot I know little :wink:

Thank you, lubucub

I’ll answer for him:

  1. He said he wasn’t using LXQt.
  2. The Openbox configuration is in ~/.config/openbox
1 Like

@[wxl]:
Sorry, I have to ask again:

…you can go into your keyboard shortcuts and assign that command to a key combination…

I find for Lubuntu:

https://help.ubuntu.com/community/Lubuntu/Keyboard#Create_New_Keyboard_shortcuts
Create New Keyboard shortcuts
There is no automatic way to create new keyboard shortcuts …

Wow! Very heavy stuff for me! Will I have to do all this mentioned in the text just for a simple new keyboard shortcut or is there some easier Lubuntu way for a brat :wink: like me spoiled by Ubuntu and Debian?

Unfortunately, there’s no simple solution for defining hotkeys in Openbox. obkey used to be a thing, but you won’t find it in the Ubuntu archives. There’s a GitHub repo but development on it has ended, so YMMV. In LXQt, there’s lxqt-globalkeys which could easily handle this. That said, you don’t need that shortcut unless your plan is to toggle at will. If not, you just need to make the script, make it executable, and add the $HOME/bin/touchpad.sh 0 line in your profile.

I should also mention this script is for turning the touchpad on and off, which is not what you want. You’ll want to change the following lines as such (basically replacing instances of “device enabled” with “tapping enabled”):

# Get current state
MY_TOUCHPAD_STATE=$(xinput list-props $MY_TOUCHPAD_ID | grep -i "tapping enabled" | cut  -f3)
# Change current state
xinput set-prop $MY_TOUCHPAD_ID "Tapping Enabled" $MY_TOUCHPAD_STATE

If for some reason that doesn’t work, reply back with the results of:

xinput list-props $(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)

I set it up to toggle because there’s always the very rare moment when I have the laptop without a mouse. Maybe the wireless mouse’s battery dies. Being able to bring the touchpad back to life is very handy. There’s always those few times when you’re thankful for that ability.

And so, I recognized the parm (0 or 1) to force it one way or the other (when logging in, via the .profile).

It would be nice if Lubuntu offered something like this out of the box. I don’t know how people live with the touchpad. I spend more than 10 minutes with the touchpad enabled and I’m ready to commit suicide. It’s amazingly frustrating to try to use the laptops’s keyboard with that thing active. Maybe I have lazy thumbs that constant tap the pad. I don’t now. But, I would give up after more than 10 minutes. I can’t function with it.

Someone mentioned on the mailing list once about using synclient to disable the touchpad depending on how long it’s been since you typed a key. That might be a good way to do it. What I can’t cope with is how typing and touching at the same time causes havoc.

I didn’t realize xinput is “better” (if I’m interpreting Walter’s prior post). Somewhere along the line I got the impression synclient was better. But, maybe that’s because it was easier to script. That was the only reason I’ve had it in the back of my mind to convert my script to synclient. I had the impression xinput was clumsy or something. I didn’t now it’s better.

Makes sense, but in the OP’s case, they want tap-to-click permanently disabled.

I’m pretty sure 19.04+ does, no?

Exactly how I feel about tap-to-click.

I use the keyboard a lot (I use awesome, a keyboard-driven tiling window manager) on a laptop with a touchpad as the pointing device and I just use unclutter to hide the pointer after inactivity. You can tweak the settings to get it to ignore 𝑥 amount of jitter and it won’t pop back up even if you accidentially hover over the touchpad.

Also looking at the synaptics manpage there are a variety of helpful properties that quite possible are options in libinput, too:

   Option "HorizHysteresis" "integer"
          The  minimum  horizontal  HW  distance  required  to generate motion events. Can be
          specified as a percentage. Increase if noise motion is a problem for you.  Zero  is
          disabled.   Default:  0.5  percent  of  the  diagonal  or  (in  case  of evdev) the
          appropriate "fuzz" as advertised by the device.

   Option "VertHysteresis" "integer"
          The  minimum  vertical  HW  distance  required  to  generate  motion  events.   See
          HorizHysteresis.

   Option "PalmDetect" "boolean"
          If   palm   detection   should   be   enabled.    Note   that  this  also  requires
          hardware/firmware support from the touchpad. Property: "Synaptics Palm Detection"

   Option "PalmMinWidth" "integer"
          Minimum finger width at which touch is considered a palm. Property: "Synaptics Palm
          Dimensions"

   Option "PalmMinZ" "integer"
          Minimum  finger  pressure at which touch is considered a palm. Property: "Synaptics
          Palm Dimensions"

The author of synaptics (of which synclient is a part of) has essentially deprecated it to focus on libinput (of which xinput is part of) instead. libinput is a little more generalized and abstracted, which makes it extremely powerful and versatile. If you really want to know more, you could always read the docs.

This my solution now that works and my simple mind :wink: can understand:

A) Create 2 scripts:

synclientTapOn.sh:
#!/bin/bash
#This script enables Tap to Click
synclient TapButton1=1

synclientTapOff.sh:
#!/bin/bash
#This script disables Tap to Click
synclient TapButton1=0

B) Put these scripts into $HOME/bin/

C) Put into my .profile:
$HOME/bin/synclidentTapOn.sh
because I use this most of my time

D) put into my User2’s .profile:
$HOME/bin/synclidentTapOff.sh
because she rarely uses Tap to Click

E) Have both scripts also in our Desktops in case we want to change the Tapping

Thank you to both of you again, azdays15 and wxl, to introduce fumbling :wink: with the innards of Lubuntu to me :slight_smile:
lubucub

Or create the script as above with the changes I suggested and stick it outside of home, e.g. /usr/bin/tap-to-click.sh and then call /usr/bin/tap-to-click.sh 0 in your $HOME/.profile and /usr/bin/tap-to-click.sh 1 in your other user’s. You can create a shortcut on the Desktop with ln -s /usr/bin/tap-to-click.sh $HOME/Desktop which will allow for toggling. This is more general and universal and it doesn’t use synaptics which, like I said, is deprecated.

@[wxl]
Sorry that i will stick to my deprecated solution till next year’s 20.04 LTS, which maybe will offer an on-board fix?

You can create a shortcut on the Desktop with ln -s /usr/bin/tap-to-click.sh $HOME/Desktop which will allow for toggling.

I did put my two scripts as new items into “Menu” > “System Tools”, using alacarte, which offers a sophisticated :wink: way of toggling now for both of us.

Actually, we should have a fix in 19.10.

@wxl
With 19.04 I use in my case, and with my touchpad,
xinput set-prop 13 307 1
or
xinput set-prop 13 307 0

That will work for your specific case, but if anything changes, you might run into trouble. The script seeks to find the id (13) more generally and refers to the setting (307) more generally as well.

@wxl
You are right, I had to readjust the setting the next day :frowning:

@wxl

xinput set-prop 13 307 1

That will work for your specific case, but if anything changes, you might run into trouble. The script seeks to find the id (13) more generally and refers to the setting (307) more generally as well.

Is there a simple way my system could automatically detect those changes? Please note that I am not a scriptmaster. And I would dearly continue using Lubuntu 19.04 after you had persuaded me to reinstall it.

You can use the script as above. Perhaps a little explanation might help make sense out of it:

Long script explanation (click to expand).

I’ll go through it line by line (except for the comments, i.e. the ones that start with #) so you can understand what’s going on.

#!/bin/bash

This is called the shebang and basically instructs the shell to use this program to run the script. In general, it will come in this format, but I prefer #!/usr/bin/env bash because it’s a bit more portable, but it’s fine as is.

echo 'touchpad.sh: DEBUG: entering' 

This and other similar lines merely output the quoted text. The purpose for this is to allow for one to understand where one is in the program execution. This is useful for debugging. Since you are not debugging, you can either leave these out or comment them. I will not comment on similar lines.

MY_TOUCHPAD_ID="$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)"

This assigns a variable, MY_TOUCHPAD_ID with the output of the string of commands inside of the parentheses. This is called command substitution. The pipes (|) take the output of the previous command and feed it into the input of the next command and each of those commands are as such:

  1. xinput list lists all of the input devices
  2. grep -i touchpad does a case insensitive (that’s the -i) search for any instance of the word touchpad in the above and outputs the result
  3. cut -d'=' -f2 print the field (that’s the -f, with the 2 specifying the second field) after = in the above. Our first command has an output that includes only one such delimiter (that’s the -d), the device ID.
  4. cut -d$'\t' -f1 prints the field before a TAB character. Since the first command includes a master/slave description after the ID, we need to remove this to isolate the ID.
if [ "$MY_TOUCHPAD_ID" == "" ]; then

This uses the conditional if-clause to test if the MY_TOUCHPAD_ID variable (by the way, the $ before the variable outputs its value and is called parameter expansion) is empty.

	exit

This exits the program, in the case that the variable is empty, as it means we don’t have a touchpad we can identify, so we shouldn’t go trying to tweak settings on it.

fi

This ends the if-clause.

if [ "$1" == "" ]; then

Another if-clause, but this is checking to see if the first positional parameter or argument to the program is empty. This allows for calling the program in the form touchpad.sh to toggle the state rather than explicitly specifying the state with the 0 or 1 argument (e.g. touchpad.sh 0 turns it off).

	MY_TOUCHPAD_STATE="$(xinput list-props $MY_TOUCHPAD_ID | grep -i "tapping enabled" | cut  -f3)"

This creates a new variable, MY_TOUCHPAD_STATE that lists the properties of of our touchpad (by ID, using the MY_TOUCHPAD_ID variable from before), then searches for tapping enabled and using the TAB character as a delimiter (though it’s not specified, it’s the default for cut), outputs the third field. This is the value of the “tapping enabled” property, a 0 or 1 value.

	if [ "$MY_TOUCHPAD_STATE" == "0" ]; then
		MY_TOUCHPAD_STATE="1"

This checks if the state is 0, and if so, sets it to 1.

	elif [ "$MY_TOUCHPAD_STATE" == "1" ]; then
		MY_TOUCHPAD_STATE="0"

This is another form of the if-clause, but one that’s nested within the clause itself. It can be read “else-if.” It checks to see if the state is 1, and if so, sets it to 0.

	else
		echo "touchpad.sh: ERROR: Could not find current touchpad status (to toggle). Setting to enabled."
		MY_TOUCHPAD_STATE="1"

This is another option in the if-clause: an option to match anything that didn’t meet the previous tests. In this case, it means the state was something other than 0 or 1, which is erroneous. The script chooses to arbitrarily set it to 1 to at least return it to a normal state.

elif [ "$1" != "0" ] && [ "$1" != "1" ]; then
	echo "touchpad.sh: ERROR: Passed argument not 0 or 1. Setting to 1."
	MY_TOUCHPAD_STATE="1"

I’m not sure you noticed it but there is actually a whole if-clause (i.e. iffi) nested within another one. The first one checked if the first argument was empty and used the second if so. This returns back to that if-clause. In the event the argument is not empty, then it checks if it is something other than 0 or 1. If this is the case, just like the last error check, this sets it to 1.

else
	MY_TOUCHPAD_STATE="$1"

We’ve tested if the first argument was empty and if it was not 0 or 1, which leaves us the only other real options: it’s either 0 or 1. In that case, the script was run with a request for an explicit state. This sets our state variable to that argument.

xinput set-prop $MY_TOUCHPAD_ID "Tapping Enabled" $MY_TOUCHPAD_STATE

Now that we have our ID and we have our state, we can simply set it using those variables.


I hope that helps you better understand how the script works and will help you in creating future scripts. The key is that the touchpad ID is acquired generally and the property is defined more generally rather than by its ID.

One thing to consider is that it really doesn’t hurt to set a property to a value it already has. That said, you can also summarize it into two really long commands:

# Turn it off
xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "Tapping Enabled" 0
# Turn it on
xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "Tapping Enabled" 1

@wxl:

After at least 2 hours of tinkering I gave up, the Touchpad scripts, that is.

A) Your short version do not work, neither as scripts, nor in a terminal, e.g.

~$ xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "Tapping Enabled" 1

property 'Tapping Enabled' doesn't exist, you need to specify its type and format

No wonder, Touchpad is not specified.

B) azdays15’s script works fine as is; but of course it just switches the whole Touchpad on or off. If I replace “Touchpad Enabled” with “Tapping Enabled” (as you suggest) nothing happens, Tapping keeps beeing disabled.

Now I really need a long break!

Thanks, lubucub

@wxl: I am so frustrated that I forgot to thank you for your very detailed explanations, Thank you :slight_smile:
“Pearls before swine”

@wxl: Touchpad script

Found a solution but it works not always: Why?

Your script

     # Turn it on
      xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "Tapping Enabled" 1  

doesn not work properly in my case, because of two “Tapping Enabled” lines in my touchpad list, see here:

    Device 'ETPS/2 Elantech Touchpad':
            Device Enabled (151):   1
            Coordinate Transformation Matrix (153): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
            libinput Tapping Enabled (307): 0
            libinput Tapping Enabled Default (308): 0

So, I changed it to

xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "Tapping Enabled (" 1

This worked fine for some time, being able to change Tap on/Tap off just replacing 1 with 0 and vice versa). But now it does not anymore, it does not tap on, and there is an errotmodification, see later :

Response after running the script:

    property 'Tapping Enabled (' doesn't exist, you need to specify its type and format

This is eve more strange sice hte property “Tapping Enabled” is correctly found in my test script, i.e., both numbers correctly turn out, MY_TOUCHPAD_ID and MY_TOUCHPAD_STATE, 13 and 0 (iTap off, the latter):

    #!/bin/bash

    # Turn it on

    MY_TOUCHPAD_ID="$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)"

    MY_TOUCHPAD_STATE="$(xinput list-props $MY_TOUCHPAD_ID | grep -i "Tapping Enabled (" | cut  -f3)"

    echo $MY_TOUCHPAD_ID
    echo $MY_TOUCHPAD_STATE

    read -p "Press [Enter] key to continue..."

    # This is your original
    # xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "Tapping Enabled" 1

    # This is my modification
    xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "Tapping Enabled (" 1

    # xinput set-prop $MY_TOUCHPAD_ID $MY_TOUCHPAD_STATE 1

    echo $MY_TOUCHPAD_ID
    echo $MY_TOUCHPAD_STATE

    read -p "Press [Enter] key to continue..."

When I run it now I get:

    13
    0
    Press [Enter] key to continue... property 'Tapping Enabled (' doesn't exist, you need to specify its type and format
    13
    0

13 and 0 are correct, but why “doesn’t exist,…”
What could be wrong?

Thanks, lubucub

Finally solved, and it is rebootproof :joy:

These are the 4 essential lines of the TapToClickOn-script for Lubuntu 19.04:

    MY_TOUCHPAD_ID="$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)"

    TOUCHPAD_STATE="$(xinput list-props $MY_TOUCHPAD_ID | grep -i "Tapping Enabled (" | cut -d '(' -f2)"

    MY_TOUCHPAD_STATE="${TOUCHPAD_STATE:0:3}"

    xinput set-prop $MY_TOUCHPAD_ID $MY_TOUCHPAD_STATE 1

To set TapOff just replace 1 with 0

I’m really confused as to why you’re searching for “Tapping Enabled (” and not “Tapping Enabled,” but I see how you worked around it to get it there, and managed some more high-level scripting, too. Good work!