Add a working toggletouchpad script

This commit is contained in:
M. Yas. Davoodeh 2020-08-01 03:02:59 +04:30
parent 4589bb0a8b
commit 8af9ee72e1
3 changed files with 14 additions and 4 deletions

View File

@ -331,8 +331,8 @@ bindsym XF86Reload restart
##bindsym XF86Launch9 exec ##bindsym XF86Launch9 exec
#bindsym XF86AudioMicMute exec $micmute #bindsym XF86AudioMicMute exec $micmute
bindsym XF86TouchpadToggle exec --no-startup-id toggletouchpad bindsym XF86TouchpadToggle exec --no-startup-id toggletouchpad
bindsym XF86TouchpadOn exec --no-startup-id synclient TouchpadOff=0 bindsym XF86TouchpadOn exec --no-startup-id toggletouchpad 1
bindsym XF86TouchpadOff exec --no-startup-id synclient TouchpadOff=1 bindsym XF86TouchpadOff exec --no-startup-id toggletouchpad 0
bindsym XF86Suspend exec --no-startup-id lockscreen bindsym XF86Suspend exec --no-startup-id lockscreen
bindsym XF86Close kill bindsym XF86Close kill
bindsym XF86WebCam exec --no-startup-id camtoggle bindsym XF86WebCam exec --no-startup-id camtoggle

View File

@ -53,9 +53,9 @@ super + x
XF86Launch1 XF86Launch1
xset dpms force off xset dpms force off
XF86TouchpadToggle XF86TouchpadToggle
(synclient | grep "TouchpadOff.*1" && synclient TouchpadOff=0) || synclient TouchpadOff=1 toggletouchpad
XF86Touchpad{Off,On} XF86Touchpad{Off,On}
synclient TouchpadOff={1,0} toggletouchpad {0,1}
XF86MonBrightnessDown XF86MonBrightnessDown
xbacklight -dec 15 xbacklight -dec 15
XF86MonBrightnessUp XF86MonBrightnessUp

10
.local/bin/toggletouchpad Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# Toggles touchpad status
# 0 as input disables the touchpad and anything else enables it. In case no input is provided, simply toggles it.
# requirements: libinput, xinput
toggleto(){ [ "$1" = "0" ] && xinput disable "$device" || xinput enable "$device" ;}
device="$(xinput list | grep -P '(?<= )[\w\s:]*(?i)(touchpad|synaptics)(?-i).*?(?=\s*id)' -o | head -n1)"
# If there is an input switch to that, otherwise just toggle
toggleto "${1:-$([ "$(xinput list-props "$device" | grep -P ".*Device Enabled.*\K.(?=$)" -o)" = "1" ] && echo 0)}"