From b610aef381ad5c61ab3caa33e43f695d2a0104e4 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 23 Aug 2021 23:25:59 +0100 Subject: [PATCH] make initwacom more flexible --- .local/bin/initwacom | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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"