dots/.bin/set-wacom-draw-area

85 lines
3.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Note: this script gets called from $HOME/.config/autorandr/docked/postswitch,
# default drawing area on 4K monitor
# Centered draw area:
#
# x_offset = screen_width/2 - draw_width/2
# y_offset = screen_height/2 - draw_height/2
#
# Drawing area
#
w=1920 # Width
h=1080 # Height
x=1920 # Horizontal offset
y=1080 # Vertical offset
orientation="landscape" # Portrait/landscape
# Get screen resolution (TODO: test external monitor)
resolution=$(xrandr --current | grep "connected primary" | awk '{print $4}')
echo "$resolution"
# Get rotation setting
rotate=`[[ "$orientation" == "landscape" ]] && echo "half" || echo "ccw"`
#
# Wacom tablet
#
# Right bottom
xsetwacom set "Wacom Intuos Pro M Pen stylus" rotate "$rotate"
xsetwacom set "Wacom Intuos Pro M Finger touch" rotate "$rotate"
xsetwacom set "Wacom Intuos Pro M Pen eraser" rotate "$rotate"
xsetwacom set "Wacom Intuos Pro M Pen cursor" rotate "$rotate"
xsetwacom set "Wacom Intuos Pro M Pen stylus" rotate "$rotate"
xsetwacom set "Wacom Intuos Pro M Pen stylus" MapToOutput "$w"x"$h"+"$x"+"$y"
xsetwacom set "Wacom Intuos Pro M Finger touch" MapToOutput "$w"x"$h"+"$x"+"$y"
xsetwacom set "Wacom Intuos Pro M Pen eraser" MapToOutput "$w"x"$h"+"$x"+"$y"
xsetwacom set "Wacom Intuos Pro M Pen cursor" MapToOutput "$w"x"$h"+"$x"+"$y"
xsetwacom set "Wacom Intuos Pro M Pen stylus" MapToOutput "$w"x"$h"+"$x"+"$y"
# Centered
# xsetwacom set "Wacom Intuos Pro M Pen stylus" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# xsetwacom set "Wacom Intuos Pro M Finger touch" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# xsetwacom set "Wacom HID 5214 Pen stylus" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# xsetwacom set "Wacom HID 5214 Finger touch" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# xsetwacom set "Wacom Intuos Pro M Pen eraser" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# xsetwacom set "Wacom Intuos Pro M Pen cursor" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# xsetwacom set "Wacom HID 5214 Pen eraser" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# xsetwacom set "Wacom Intuos Pro M Pen stylus" MapToOutput 1920x1080+"$(w/2)"+"$(h/2)"
# # Rotate drawing are for vertical drawing
# # (physical controls above drawing area)
# xsetwacom set "Wacom Intuos Pro M Pen stylus" rotate ccw
# xsetwacom set "Wacom Intuos Pro M Finger touch" rotate ccw
# xsetwacom set "Wacom HID 5214 Pen stylus" rotate ccw
# xsetwacom set "Wacom HID 5214 Finger touch" rotate ccw
# xsetwacom set "Wacom Intuos Pro M Pen eraser" rotate ccw
# xsetwacom set "Wacom Intuos Pro M Pen cursor" rotate ccw
# xsetwacom set "Wacom HID 5214 Pen eraser" rotate ccw
# xsetwacom set "Wacom Intuos Pro M Pen stylus" rotate ccw
# # Set drawing area to left side on 3840x2160 monitor
# xsetwacom set "Wacom Intuos Pro M Pen stylus" MapToOutput 1080x1920+130+130
# xsetwacom set "Wacom Intuos Pro M Finger touch" MapToOutput 1080x1920+130+130
# xsetwacom set "Wacom HID 5214 Pen stylus" MapToOutput 1080x1920+130+130
# xsetwacom set "Wacom HID 5214 Finger touch" MapToOutput 1080x1920+130+130
# xsetwacom set "Wacom Intuos Pro M Pen eraser" MapToOutput 1080x1920+130+130
# xsetwacom set "Wacom Intuos Pro M Pen cursor" MapToOutput 1080x1920+130+130
# xsetwacom set "Wacom HID 5214 Pen eraser" MapToOutput 1080x1920+130+130
# xsetwacom set "Wacom Intuos Pro M Pen stylus" MapToOutput 1080x1920+130+130
#
# Laptop touch display
#
xsetwacom set "Wacom HID 5214 Pen stylus" rotate none
xsetwacom set "Wacom HID 5214 Finger touch" rotate none
xsetwacom set "Wacom HID 5214 Pen eraser" rotate none
xsetwacom set "Wacom HID 5214 Pen eraser" MapToOutput 1920x1080+0+0
xsetwacom set "Wacom HID 5214 Pen stylus" MapToOutput 1920x1080+0+0
xsetwacom set "Wacom HID 5214 Finger touch" MapToOutput 1920x1080+0+0