2018-07-12 at 7:01 AM UTC
aldra
JIDF Controlled Opposition
I put this together last night when I realised lunix acpi didn't recognise my laptop's 'disable trackpad' shortcut (fn+F9) - it uses xinput to detect the device ID and status to enable/disable it. I have it attached to an openbox keybind. Nothing complicated, thought it might be useful to someone else though.
#!/bin/bash
# aldra 2018
# using xinput, find the integrated trackpad and toggle it on/off
deviceRaw=$(xinput --list|grep -i touchpad|grep -P -o "id=.*\t") # force perl regex as posix apparently doesn't escape tab to \t
deviceClean=${deviceRaw//[!0-9]/} # retrieve numbers only
deviceState=$(xinput list-props "$deviceClean" | grep -i enabled | grep -o "[01]$")
if [ $deviceState == '1' ];then
xinput --disable "$deviceClean"
echo "Touchpad on $deviceClean disabled."
else
xinput --enable "$deviceClean"
echo "Touchpad on $deviceClean enabled."
fi
I'm aware that there are cleaner ways to do the string manipulation. You can replace 'touchpad' in the deviceRaw line with whatever device you want (xinput --list for a list of them)
The following users say it would be alright if the author of this
post didn't die in a fire!
2018-07-13 at 6:38 AM UTC
this post is here to make OP less lonely.
2018-07-13 at 6:44 AM UTC
aldra
JIDF Controlled Opposition
thank mr skeltal
I remember there was a bash/shellscript thread somewhere but couldn't find it.
I'm going through python code now, seems fairly straightforward but enforced whitespace is annoying
2018-07-14 at 6:55 PM UTC
The author of this post has returned to nothingness