diff --git a/.local/bin/initwacom b/.local/bin/initwacom index bedde58..8cfbb40 100755 --- a/.local/bin/initwacom +++ b/.local/bin/initwacom @@ -16,11 +16,20 @@ if [ -z "${pad}" ]; then exit 0 fi -xsetwacom set "${stylus}" MapToOutput DisplayPort-1 -xsetwacom set "${eraser}" MapToOutput DisplayPort-1 +first_display="$(xrandr | grep -oP "([^\s]+)(?=\sconnected)" | head -1)" -xsetwacom set "${stylus}" Area "0 0 31496 17716" -xsetwacom set "${eraser}" Area "0 0 31496 17716" +xsetwacom set "${stylus}" MapToOutput "${first_display}" +xsetwacom set "${eraser}" MapToOutput "${first_display}" + +first_resolution="$(xrandr | grep -oP "(\d+x\d+)(?=[^*]+\*)" | head -1)" +IFS='x' +read -ra resolution <<< "$first_resolution" + +width=31496 +height="$(bc -l <<< "ratio=${resolution[0]}/${resolution[1]}; scale=0; $width/ratio")" + +xsetwacom set "${stylus}" Area "0 0 $width $height" +xsetwacom set "${eraser}" Area "0 0 $width $height" xsetwacom set "${pad}" Button 11 "key +ctrl z -ctrl" xsetwacom set "${pad}" Button 10 "key +shift"