Skip to content

Instantly share code, notes, and snippets.

@bkanuka
Last active August 29, 2015 14:02
Show Gist options
  • Save bkanuka/71741fc477f923054ef4 to your computer and use it in GitHub Desktop.
Save bkanuka/71741fc477f923054ef4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
TRACKPOINT_NAME="DualPoint Stick"
TRACKPAD_NAME="AlpsPS/2 ALPS GlidePoint"
POLL_INTERVAL=1.0s
point_xid=$(xinput --list --id-only "$TRACKPOINT_NAME")
pad_xid=$(xinput --list --id-only "$TRACKPAD_NAME")
is_enabled() {
en=$(xinput --list-props "$1" | grep -i Enabled | awk '{print $4}')
[ $en = '1' ]
}
in_use() {
node=$(xinput --list-props "$1" | grep -i "Device Node" | awk '{print $4}')
node="${node%\"}"
node="${node#\"}"
timeout $POLL_INTERVAL xxd -p -l 1 $node > /dev/null
}
trap "exit" INT
while true; do
if in_use $point_xid; then
# TrackPoint is in use
if is_enabled $pad_xid; then
# TrackPad is Enabled
xinput --disable $pad_xid
fi
sleep $POLL_INTERVAL
else
# TrackPoint is not in use
if ! is_enabled $pad_xid; then
# TrackPad is not enabled
xinput --enable $pad_xid
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment