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 way of toggling now for both of us.
@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
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:
xinput list
lists all of the input devicesgrep -i touchpad
does a case insensitive (thatâs the-i
) search for any instance of the wordtouchpad
in the above and outputs the resultcut -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.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. if
âŚfi
) 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
â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
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!
@wxl:
Thanks, and quite simple: without â(â I get a longer string to slice, e.g.,
289): 1 290): 0
i.e., the first plus the second lineâs information
while with " (" I get the shorter information from the first line only
289): 1
Thatâs all, nothing special about it, just my curiosity how to handle this tricky business in different ways.
Oh, I see the issue. Youâre trying to get the ID of the property. Originally I suggested that using the name of the property rather than the ID would be more general and would be less likely to get you in trouble. The problem was my assumption that the property was called âTapping Enabledâ when itâs actually âlibinput Tapping Enabled.â If you used that, it would likely be better.
Thank you, works perfect now:
#!/bin/bash
# Turn it on
xinput set-prop "$(xinput list | grep -i touchpad | cut -d'=' -f2 | cut -d$'\t' -f1)" "libinput Tapping Enabled" 1
This question by lubucub highlights a severe weakness of Lubuntu, in that there is no GUI for touchpad settings or mouse double-click times etc.
Surely, the simplest answer to the question is to add the command to Autostart in the LXSession Configuration GUI in the Preferences menu?
This is a severe weakness only of LXDE. If you read the entire thread, youâll notice the next version of Lubuntu will contain a fix for LXQt.
This brings me to the point Iâve been saying over and over and over again: DONâT USE 18.04/LXDE and instead upgrade to 19.04+/LXQt. LXDE is dead. I donât care what people say. The upstream developers are not fixing bugs, let alone adding features. Thatâs de facto dead.
The original question referred to 18.04, and there are many good reasons for LTS users not to upgrade yet, unless they are looking for a new hobby.
I have a nice, stable, 18.04 system. In a few yearsâ time, I might consider upgrading is worth the hassle, but certainly not at the moment.
Like the fact that there are âsevere weaknessesâ in it?
Yes, one that comes with a totally unreliable file manager.
What hassle is there?