2019-10-23 12:51:34 +00:00
|
|
|
#!/usr/bin/env fish
|
2019-10-20 23:25:57 +00:00
|
|
|
|
|
|
|
function set_device
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
set -g DEVICE "Wacom USB Bamboo PAD Pen stylus"
|
|
|
|
set -g DEVICETOUCH "Wacom USB Bamboo PAD Finger touch"
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
set -g WACOMPROPTOUCHSPEED "Device Accel Velocity Scaling"
|
|
|
|
set -g WACOMPROPSCROLLPSEED "ScrollDistance"
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
xsetwacom set "$DEVICE" ResetArea
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
set -l AREATOT (xsetwacom get "$DEVICE" Area)
|
|
|
|
set -g AREAX (echo $AREATOT | awk '{print $3}')
|
|
|
|
set -g AREAY (echo $AREATOT | awk '{print $4}')
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-20 23:25:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function set_screen
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
set CONNECTED_DISPLAYS (xrandr -q --current | \
|
|
|
|
sed -n 's/^\([^ ]\+\) connected .*/\1/p') desktop
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
set -g SCREEN (for d in $CONNECTED_DISPLAYS
|
|
|
|
echo $d
|
|
|
|
end | rofi -dmenu -i -p "Select your dispaly" | tr -d '\n')
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
set -l LINE (xrandr -q --current | if [ "$SCREEN" = "desktop" ]
|
|
|
|
sed -n 's/^Screen 0:.*, current \([0-9]\+\) x \([0-9]\+\),.*/\1 \2/p'
|
|
|
|
else
|
|
|
|
sed -n "s/^$SCREEN"' connected \(primary \)\{0,1\}\([0-9]\+\)x\([0-9]\+\)+.*/\2 \3/p'
|
|
|
|
end)
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
echo $LINE | read -g WIDTH HEIGHT
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
if test -z $WIDTH || test -z $HEIGHT
|
|
|
|
exit 1
|
|
|
|
end
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-20 23:25:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function adjust_device
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
set RATIOAREAY (math ceil \($AREAX \* $HEIGHT \/ $WIDTH\))
|
|
|
|
set RATIOAREAX (math ceil \($AREAY \* $WIDTH \/ $HEIGHT\))
|
2019-10-20 23:25:57 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
if test $AREAY -gt $RATIOAREAY
|
|
|
|
set -g NEWAREAX $AREAX
|
|
|
|
set -g NEWAREAY $RATIOAREAY
|
|
|
|
else
|
|
|
|
set -g NEWAREAX $RATIOAREAX
|
|
|
|
set -g NEWAREAY $AREAY
|
|
|
|
end
|
2019-10-20 23:25:57 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
xsetwacom set "$DEVICE" Area 0 0 $NEWAREAX $NEWAREAY
|
|
|
|
xsetwacom set "$DEVICE" MapToOutput "$SCREEN"
|
2019-10-20 23:25:57 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
xinput set-float-prop $DEVICETOUCH $WACOMPROPTOUCHSPEED 0.5
|
2019-10-20 23:25:57 +00:00
|
|
|
|
2019-10-23 12:51:34 +00:00
|
|
|
xsetwacom set $DEVICETOUCH $WACOMPROPSCROLLPSEED "90"
|
2019-10-23 12:15:12 +00:00
|
|
|
|
2019-10-20 23:25:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
set_device
|
|
|
|
set_screen
|
|
|
|
adjust_device
|