s4ros icon

dockmode.sh

s4ros | PRO | 02/17/22 07:01:20 PM UTC | 0 ⭐ | 1080 👁️ | Never ⏰ | []
Bash |

580 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
 
_get_xinput_id() {
    echo $(xinput | grep "$1" | sed -n 's/^.*id=\([0-9]*\)\s*.*$/\1/p')
}
 
TOUCHPAD=$(_get_xinput_id "Touchpad")
TOUCHPAD_MASTER=$(_get_xinput_id "Virtual core pointer")
KEYBOARD=$(_get_xinput_id "AT Translated")
KEYBOARD_MASTER=$(_get_xinput_id "Virtual core keyboard")
 
case "$1" in
    on)
      xinput float $TOUCHPAD
      xinput float $KEYBOARD
      ;;
    off)
      xinput reattach $TOUCHPAD $TOUCHPAD_MASTER
      xinput reattach $KEYBOARD $KEYBOARD_MASTER
      ;;
    *)
      cat <<-EOF
        Usage: $0 on/off
EOF
esac
 

Comments