You are not logged in.
Hi there,
First off hello all, I'm new here! Just finised installing Arch on my thinkpad x220 and am working my way through the amazing wiki doing all the configurations.
I'm using the i3 window manager and wanted to configure my touchpad toggle on/off using the Fn button and a simple bash script using this guide here.
#!/bin/bash
if synclient -l | grep "TouchpadOff .*=.*0" ; then
synclient TouchpadOff=1 ;
else
synclient TouchpadOff=0 ;
fiAs I understand it reading here, the synaptics driver is being superceded by the libinput driver, however it appears that libinput does not support direct intervention via synclient.
Is there another way to implement a touchpad toggle on/off?
Last edited by darch (2017-02-08 21:31:40)
Offline
Okay, this is hacky as hell, but it works using xinput instead of synclient.
#!/bin/bash
ID=`xinput --list | grep "TouchPad" | awk '{ print $6 }' | sed 's/id=//'`
status=`xinput list-props $ID | grep "Device Enabled" | awk '{ print $4 }'`
if [ $status == 1 ] ; then
xinput set-prop $ID "Device Enabled" 0
else
xinput set-prop $ID "Device Enabled" 1
fiWhat this does it listing all your input devices, greps your touchpad and get its ID, checks whether it's already disabled via list-props, and if not, passes the disable command via set-props. If it is disabled, it does the same but passes the enable command.
If it doesn't work, echo the variables and make sure that awk gets the right things.
I am sure that there is a much cleaner solution, though.
Last edited by Ranmaru (2016-09-07 12:24:31)
Offline
Okay, this is hacky as hell, but it works using xinput instead of synclient.
How about:
#!/bin/bash
if [ `xinput list-props "SynPS/2 Synaptics TouchPad" | grep "Device Enabled" | awk '{ print $4 }'` == 1 ]; then
xinput disable "SynPS/2 Synaptics TouchPad"
else
xinput enable "SynPS/2 Synaptics TouchPad"
fiNot tested. Not a Bash jockey I am sure there exists a better way to find the enabled state. Check the name of your device and change the script as appropriate.
Personally, I have my system to disable the touchpad when I close the lid otherwise startling things happen and I'll open the lid to find hundreds of windows open. I use acpi, like this:
#!/bin/bash
# Default acpi script that takes an entry for all actions
case "$1" in
button/power)
case "$2" in
PBTN|PWRF)
logger 'PowerButton pressed'
;;
*)
logger "ACPI action undefined: $2"
;;
esac
;;
button/sleep)
case "$2" in
SLPB|SBTN)
logger 'SleepButton pressed'
;;
*)
logger "ACPI action undefined: $2"
;;
esac
;;
ac_adapter)
case "$2" in
AC|ACAD|ADP0)
case "$4" in
00000000)
logger 'AC unpluged'
;;
00000001)
logger 'AC pluged'
;;
esac
;;
*)
logger "ACPI action undefined: $2"
;;
esac
;;
battery)
case "$2" in
BAT0)
case "$4" in
00000000)
logger 'Battery online'
;;
00000001)
logger 'Battery offline'
;;
esac
;;
CPU0)
;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/lid)
case "$3" in
close)
export XAUTHORITY=`ls -1 /home/*/.Xauthority | head -n 1`
export DISPLAY=":`ls -1 /tmp/.X11-unix/ | sed -e s/^X//g | head -n 1`"
xinput disable "SynPS/2 Synaptics TouchPad"
#synclient TouchpadOff=1
logger 'LID closed, touchpad off'
;;
open)
logger 'LID opened, touchpad on'
export XAUTHORITY=`ls -1 /home/*/.Xauthority | head -n 1`
export DISPLAY=":`ls -1 /tmp/.X11-unix/ | sed -e s/^X//g | head -n 1`"
xinput enable "SynPS/2 Synaptics TouchPad"
#synclient TouchpadOff=0
;;
*)
logger "ACPI action undefined: $3"
;;
esac
;;
*)
logger "ACPI group/action undefined: $1 / $2"
esac
;;Last edited by ewaller (2016-09-07 14:14:13)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
God kills a kitten every time you pipe through grep to awk.
xinput list-props "SynPS/2 Synaptics TouchPad" | grep -q "Device Enabled [^:]*: *1" &&
xinput disable "SynPS/2 Synaptics TouchPad" ||
xinput enable "SynPS/2 Synaptics TouchPad""UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Avoid foo && bar || baz
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Offline
That's not a problem in this case. If it should be disabled and fails to disable, enabling it will do no harm.
Avoid overapplying heuristics without thinking about their current application ![]()
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
God kills a kitten every time you pipe through grep to awk.
Yeah, I know. Could have written the whole thing in awk to begin with. I decided to just make a first pass at improving what had been posted.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
God kills a kitten every time you pipe through grep to awk.
xinput list-props "SynPS/2 Synaptics TouchPad" | grep -q "Device Enabled [^:]*:*1" && xinput disable "SynPS/2 Synaptics TouchPad" || xinput enable "SynPS/2 Synaptics TouchPad"
Hi there, thanks for this elegant solution. Sorry for necro bumping, but I forgot about this thread.
I've found that the grep regex above will find the line whether the device is enabled or disabled, so changing the regex slightly removed the false positives. Not sure why it wasn't working before.
My final code:
if xinput list-props "SynPS/2 Synaptics TouchPad" | grep -q "Device Enabled [^:]*:[^10]*1"; then
xinput disable "SynPS/2 Synaptics TouchPad"
else
xinput enable "SynPS/2 Synaptics TouchPad"
fiThen in my i3 config file I added the following line:
XF86TouchpadToggle exec ~/path/to/bash_script.shThanks again.
Offline
Sorry, somehow a space got lost after the colon. I've revised the earlier post.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
It's not a space but a tab on my system... So that'd be it for me:
xinput list-props "SynPS/2 Synaptics TouchPad" | grep -q "Device Enabled [^:]*: 1" &&
xinput disable "SynPS/2 Synaptics TouchPad" ||
xinput enable "SynPS/2 Synaptics TouchPad"Offline