Skip to content

Instantly share code, notes, and snippets.

@klange
Last active October 9, 2015 17:37
Show Gist options
  • Save klange/3550009 to your computer and use it in GitHub Desktop.
Save klange/3550009 to your computer and use it in GitHub Desktop.
Switch the display your Wacom tablet is bound to with ease
#!/bin/bash
let DISPLAY_COUNT=3
let DISPLAY_WIDTH=1920
let DISPLAY_HEIGHT=1080
if [[ ! -f ~/.wacom-switcher-display ]]; then
echo "hmf"
echo "0" > ~/.wacom-switcher-display
fi
if [[ "$1" == "--help" ]]; then
echo You probably want --set-buttons
exit 0
elif [[ "$1" == "--next" ]]; then
let OUTPUT=`cat ~/.wacom-switcher-display`+1
elif [[ "$1" == "--previous" ]]; then
let OUTPUT=`cat ~/.wacom-switcher-display`-1
elif [[ "$1" == "--set-buttons" ]]; then
echo "Setting up control buttons"
xsetwacom set "Wacom Bamboo pad" Button 1 "key ctrl shift alt r"
xsetwacom set "Wacom Bamboo pad" Button 3 "key ctrl shift alt e"
exit 0
else
let OUTPUT=$1
fi
if [ "$OUTPUT" -ge "$DISPLAY_COUNT" ]; then
let OUTPUT=0
fi
if [ "$OUTPUT" \< "0" ]; then
let OUTPUT="$DISPLAY_COUNT - 1"
fi
echo "Switching to display $OUTPUT..."
echo "$OUTPUT" > ~/.wacom-switcher-display
let DISPLAY_OFFSET="$OUTPUT * $DISPLAY_WIDTH"
xsetwacom set "Wacom Bamboo stylus" MapToOutput "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}+${DISPLAY_OFFSET}+0"
xsetwacom set "Wacom Bamboo eraser" MapToOutput "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}+${DISPLAY_OFFSET}+0"
xsetwacom set "Wacom Bamboo cursor" MapToOutput "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}+${DISPLAY_OFFSET}+0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment