forked from druths/helix-utils
/
helix-toggle-touch
executable file
·32 lines (26 loc) · 989 Bytes
/
helix-toggle-touch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# This script will toggle the capacitive digitiser on and off so that
# the pen may be used without interference. It accepts no options, but will follow
# the device name set in the thinkpad-helix-utils config file.
# The xinput name of the touch digitiser
touch_name="Atmel Atmel maXTouch Digitizer"
# Import the configuration file if there is one. This will replace any options set above.
configfile="$HOME/.config/thinkpad-helix-utils/config"
if [[ -f "$configfile" ]]; then
source "$configfile"
fi
# Check for the device
if [ $(xinput | grep "$touch_name" | wc -l) -ne 1 ]; then
echo "Input device $touch_name not found."
exit
fi
# Toggle digitiser state
if [ $(xinput list-props "$touch_name" | grep "Device Enabled" | sed -n 's/.*\([0-9]\)$/\1/p') -eq 1 ]; then
echo "Digitiser enabled, disabling..."
xinput set-prop "$touch_name" "Device Enabled" 0
exit
else
echo "Digitiser disabled, enabling..."
xinput set-prop "$touch_name" "Device Enabled" 1
exit
fi