Brodie Robertson did a YouTube video on how to toggle on/off any input device using xorg xinput. In the video, he used his laptop touchpad as an example. This is exactly what I need to do as my touchpad is VERY sensitive and the keyboard toggle key doesn’t work. This is a known issue with my laptop, a Lenovo Yoga 900-13ISK. I downloaded the script from his GitHub repository and made the appropriate entry in my sxhkdrc following his video. Unfortunately, when I press the assigned key (F6 in my case) nothing changes with the touchpad. Using xinput list I get the following for my touchpad: Synaptics TM0036-002 id=11
Here is his script:
#!/bin/sh
# Script to toggle my laptops touchpad
#id="$(xinput list | grep -Eo 'Touchpad.*id=[0-9]*' | grep -Eo '[0-9]*')"
mode="$(echo "Synaptics TM3066-002" | xargs -I % xinput --list-props % | grep 'Device Enabled' | grep -Eo ':.*[0|1]' | grep
-Eo '[0|1]')"
if [ "$mode" -eq "1" ]; then
xinput set-prop "$id" "Device Enabled" 0 && notify-send "Touchpad" "Touchpad has been disabled"
else
xinput set-prop "$id" "Device Enabled" 1 && notify-send "Touchpad" "Touchpad has been enabled"
fi
Is the id line supposed to be commented out? Maybe you want something like id="11" based on your xinput list result, or just replace Touchpad in that line with Synaptics and uncomment it (assuming you don’t have any other xinputs that have the word Synaptics).
I replaced Touchpad with ‘Synaptics’ as you suggested but no change. I’ll try changing the id. I thought the first line of the script was to get the id number which would then be used in the if/else part of the script.
Some additional information, when I run the script manually, I get
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
./toggletouch: line 7: -Eo: command not found
./toggletouch: line 8: [: : integer expression expected
unable to find device 3066
002
11
One problem seems to be that you added a new line within the line getting mode, which messes up the grep command. Make sure that in your copy of the script there is no new line.
Also, can you post the output of xinput list and of xinput list | grep -Eo 'Synaptics.*id=[0-9]*' | grep -Eo '[0-9]*'?
What about xinput list | grep -Eo 'Synaptics.*id=[0-9]*' | grep -Eo 'id=[0-9*]' | grep -Eo '[0-9]*'
It’s probably not the cleanest solution, but I think it will work.
First, just use the command xinput list | grep -Eo 'Synaptics.*id=[0-9]*' | grep -Eo 'id=[0-9*]' | grep -Eo '[0-9]*' in the command line. I think it should get 11 as the output, if not we’ll have to do further adjustments.
If it does get 11, replace the bit in parentheses in the id expression with that command, since that one gets the right id for the touchpad.
The reason your script isn’t working is that the line trying to get the id is getting multiple numbers, only one of which is the id. I think my change to that expression would fix it, but running the command on the command line will check that it gets the right answer.
Sorry, I had a typo. The * should go outside the square brackets, not inside. xinput list | grep -Eo 'Synaptics.*id=[0-9]*' | grep -Eo 'id=[0-9]*' | grep -Eo '[0-9]*'