diff --git a/.config/i3/config b/.config/i3/config index 5553699c..a3eb3f56 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -331,8 +331,8 @@ bindsym XF86Reload restart ##bindsym XF86Launch9 exec #bindsym XF86AudioMicMute exec $micmute bindsym XF86TouchpadToggle exec --no-startup-id toggletouchpad -bindsym XF86TouchpadOn exec --no-startup-id synclient TouchpadOff=0 -bindsym XF86TouchpadOff exec --no-startup-id synclient TouchpadOff=1 +bindsym XF86TouchpadOn exec --no-startup-id toggletouchpad 1 +bindsym XF86TouchpadOff exec --no-startup-id toggletouchpad 0 bindsym XF86Suspend exec --no-startup-id lockscreen bindsym XF86Close kill bindsym XF86WebCam exec --no-startup-id camtoggle diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 1b893724..c114aebb 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -53,9 +53,9 @@ super + x XF86Launch1 xset dpms force off XF86TouchpadToggle - (synclient | grep "TouchpadOff.*1" && synclient TouchpadOff=0) || synclient TouchpadOff=1 + toggletouchpad XF86Touchpad{Off,On} - synclient TouchpadOff={1,0} + toggletouchpad {0,1} XF86MonBrightnessDown xbacklight -dec 15 XF86MonBrightnessUp diff --git a/.local/bin/toggletouchpad b/.local/bin/toggletouchpad new file mode 100755 index 00000000..5df89cde --- /dev/null +++ b/.local/bin/toggletouchpad @@ -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)}"