This script maximizes active area of Wacom tablet with respect to proper ratio. It also rotates your tablet, if necessary.
- #!/bin/bash
- #
- # This program is under GPLv3 license --
- # http://www.gnu.org/licenses/gpl-3.0.html
- #
- # If you think, that this script is usefull, please send me a postcard to
- # adress:
- # Michal Nanasi
- # Azalkova 1
- # 82101 Bratislava
- # Slovakia
- resolutionW=`xrandr |grep current | sed -e 's/.*current \([0-9]*\) x \([0-9]*\),.*$/\1/'`
- resolutionH=`xrandr |grep current | sed -e 's/.*current \([0-9]*\) x \([0-9]*\),.*$/\2/'`
- export IFS=$' ';
- wacomdev=`xidump -l |grep Wacom |sed -e 's/[ ]*extension.*$//' | sort`
- firstDev=`echo $wacomdev | head -n 1`
- export IFS=$'\n'
- xsetwacom set "$firstDev" xyDefault
- wacomW=`xsetwacom get "Wacom BambooFun 6x8" BottomX`
- wacomH=`xsetwacom get "Wacom BambooFun 6x8" BottomY`
- if (($resolutionW*$wacomH<$resolutionH*$wacomW)) ; then
- normalWidth=$(($resolutionW*$wacomH/$resolutionH))
- normalHeight=$wacomH
- else
- normalWidth=$wacomW
- normalHeight=$(($resolutionH*$wacomW/$resolutionW))
- fi
- if (($resolutionW*$wacomW<$resolutionH*$wacomH)) ; then
- rotateHeight=$(($resolutionW*$wacomW/$resolutionH))
- rotateWidth=$wacomW
- else
- rotateHeight=$wacomH
- rotateWidth=$(($resolutionH*$wacomH/$resolutionW))
- fi
- if (($normalWidth*$normalHeight > $rotateWidth*$rotateHeight)) ; then
- for dev in $wacomdev; do
- xsetwacom set "$dev" BottomX $normalWidth
- xsetwacom set "$dev" BottomY $normalHeight
- xsetwacom set "$dev" Rotate NONE
- notify-send 'Tablet is NOT rotated'
- done
- else
- for dev in $wacomdev; do
- xsetwacom set "$dev" BottomX $rotateWidth
- xsetwacom set "$dev" BottomY $rotateHeight
- xsetwacom set "$dev" Rotate CW
- notify-send 'Tablet is rotated'
- done
- fi
