summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/tab-scale
blob: 25992a314a8943e8e075b4777f14c4ebda26d93b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash

args=("$@")

stylus=$(xsetwacom list | grep stylus | cut -f 1 | xargs)


Wx=${args[0]}
Wy=${args[1]}
alpha=${args[2]}
Sx=${args[3]}
Sy=${args[4]}
skewX=${args[5]}
skewY=${args[6]}

xsetwacom --set "$stylus" ResetArea
Nx=$(xsetwacom get "$stylus" Area | cut -f 3 -d ' ')
Ny=$(xsetwacom get "$stylus" Area | cut -f 4 -d ' ')

resX=$(xdpyinfo | awk '/dimensions/{print $2}' | cut -f 1 -d 'x')
resY=$(xdpyinfo | awk '/dimensions/{print $2}' | cut -f 2 -d 'x')

#dual display hack
#resX=$(($resX/2))

Nxx=$(($Nx/$alpha))
Nyy=$(($Sx*$Ny*$Wy/$alpha/$Sy/$Wx))

dx=$((($resX-$Wx)/2 + $skewX))
dy=$((($resY-$Wy)/2 + $skewY))

#echo $stylus
#echo Area 0 0 $Nxx $Nyy
#echo MapToOutput ${Wx} ${Wy} ${dx} ${dy}

#xsetwacom --set "${stylus}" Area 0 0 $Nxx $Nyy
xsetwacom --set "${stylus}" Area $((($Nx-$Nxx)/2)) 0 $((($Nx+$Nxx)/2)) $Nyy
#xsetwacom --set "${stylus}" Area 0 $(($Ny-$Nyy)) $Nxx $Ny
xsetwacom --set "${stylus}" MapToOutput ${Wx}x${Wy}+$dx+$dy


# map stylus buttons
# stylus touch to mouse left click
xsetwacom --set "${stylus}" button 1 1
# stylus low button press to mouse middle click
xsetwacom --set "${stylus}" button 2 2
# stylus high button press to mouse right click
xsetwacom --set "${stylus}" button 3 3


# map tablet buttons
pad=$(xsetwacom list | grep 'Pad pad' | cut -f 1 | xargs)

xsetwacom --set "$pad" Button 1 "key +shift +alt p -alt -shift"
xsetwacom --set "$pad" Button 2 "key +shift +alt a -alt -shift"
xsetwacom --set "$pad" Button 3 12
xsetwacom --set "$pad" Button 8 13
xsetwacom --set "$pad" Button 9 14
xsetwacom --set "$pad" Button 10 "key +shift +alt l -alt -shift"
xsetwacom --set "$pad" Button 11 "key +shift +alt s -alt -shift"
xsetwacom --set "$pad" Button 12 "key +ctrl z -ctrl"