Skip to content

Instantly share code, notes, and snippets.

@Jakobimatrix
Last active June 17, 2022 14:11
Show Gist options
  • Save Jakobimatrix/6dd9b73839a0d06f25e78e957083ec10 to your computer and use it in GitHub Desktop.
Save Jakobimatrix/6dd9b73839a0d06f25e78e957083ec10 to your computer and use it in GitHub Desktop.
Scripts for fast changing modes of Wacom Tablet devices
#!/bin/bash
# Toggle the sensitivity of your Wacom Tablet
# BEFORE usage define your DEVICE:
# use: xsetwacom --list devices
# to find your device
# You probably need to adapt the RESET condition for your tablet:
# get cour current resolution using: xsetwacom --get "$DEVICE" Area
DEVICE="Wacom Intuos S 2 Pen stylus"
RESET="0 0 15200 9500"
area_string=$(xsetwacom --get "$DEVICE" Area)
# shellcheck disable=SC2206 # I want to split the words here not prevent it!
IFS=' ' area=($area_string)
if [[ ${#area[@]} != 4 ]]; then
echo "Fehler area has not the expected size"
exit 1
fi
usage() {
echo "Usage scale up: $0 [-u <0-9>]" 1>&2; exit 1;
echo "Usage scale down: $0 [-d <0-9>]" 1>&2; exit 1;
echo "Usage scale reset: $0" 1>&2; exit 1;
}
scale=0
scale_dir=0
while getopts ":u:d:" o; do
case "${o}" in
u)
scale=${OPTARG}
scale_dir=-1
;;
d)
scale=${OPTARG}
scale_dir=1
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
re='^[0-9]+$'
if ! [[ $scale =~ $re ]]; then
usage
fi
if ((scale < 0 || scale > 10)); then
usage
fi
if [[ $scale_dir == 0 ]]; then
xsetwacom --set "$DEVICE" Area "$RESET"
elif [[ $scale_dir == -1 ]]; then
wx=$((area[2] / scale))
wy=$((area[3] / scale))
xsetwacom --set "$DEVICE" Area 0 0 $wx $wy
else
wx=$((area[2] * scale))
wy=$((area[3] * scale))
xsetwacom --set "$DEVICE" Area 0 0 $wx $wy
fi
exit 0
#!/bin/bash
# Toggle the input mode between 'relative' and 'absolute' of your Wacom Tablet
# BEFORE usage define your DEVICE:
# use: xsetwacom --list devices
# to find your device
DEVICE="Wacom Intuos S 2 Pen stylus"
MODE=$(xsetwacom --get "$DEVICE" Mode)
if [[ "$MODE" == "Relative" ]]; then
xsetwacom --set "$DEVICE" Mode "Absolute"
elif [[ "$MODE" == "Absolute" ]]; then
xsetwacom --set "$DEVICE" Mode "Relative"
else
echo "$DEVICE not installed!"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment