Created
February 7, 2020 02:29
-
-
Save diamondburned/09e0ddb6848009a9b96f24759c780cf4 to your computer and use it in GitHub Desktop.
Wacom tablet config script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
config() { | |
orig[X]=15200 | |
orig[Y]=9500 | |
offset[X]=0 | |
offset[Y]=0 | |
# relative/absolute | |
mode=absolute | |
# relative args | |
scale=${1:-5} # 1/5 | |
# absolute args | |
abs[X]=${1:-2533} | |
abs[Y]=${2:-1583} | |
# display resolution | |
disp[x]=2560 | |
disp[y]=1440 | |
} | |
main() { | |
id=$(xsetwacom --list devices | grep stylus | cut -d $'\t' -f 2 | cut -d ' ' -f2) | |
declare -A orig | |
declare -A abs | |
declare -A offset | |
declare -A disp | |
config # load config | |
case $mode in | |
relative) | |
[[ $scale ]] || fatal "Scale is empty" | |
abs[X]=$[ ${orig[X]} / $scale ] | |
abs[Y]=$[ ${orig[Y]} / $scale ] | |
;& # fallthrough | |
absolute) | |
xsetwacom --set $id Area ${offset[X]} ${offset[Y]} ${abs[X]} ${abs[Y]} | |
broadcast "Area set to (${abs[X]},${abs[Y]}), offset (${offset[X]},${offset[Y]})" | |
;; | |
*) | |
>&2 echo "Unknown mode" | |
exit 2 | |
esac | |
#xsetwacom --set $id MapToOutput 1920x$[ 1080 * ${orig[X]} / ${orig[Y]} ]+0+0 | |
xsetwacom --set $id MapToOutput ${disp[x]}x${disp[y]}+0+0 | |
xsetwacom --set $id RawSample 2 | |
xsetwacom --set $id Suppress 2 | |
broadcast "Smoothing disabled" | |
exit | |
[[ $1 ]] && { | |
while read -r x; do | |
y=$[ x * 9500 / 15200 ] | |
xsetwacom --set $id Area 0 0 $x $y | |
echo "Set to $x $y" | |
done | |
} | |
} | |
broadcast() { | |
gdbus call -e \ | |
-d "org.freedesktop.Notifications" \ | |
-o /org/freedesktop/Notifications \ | |
-m "org.freedesktop.Notifications.Notify" \ | |
"" 0 "" "tablet-conf" "$*" "[]" "{}" -1 &> /dev/null | |
echo "$@" | |
} | |
fatal() { | |
>&2 echo "$@" | |
exit 2 | |
} | |
main "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment