-
Notifications
You must be signed in to change notification settings - Fork 1
/
dmenuWacom
executable file
·123 lines (101 loc) · 3.93 KB
/
dmenuWacom
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/env zsh
# ░█▀▄░█▄█░█░█░█▀█░█▀▀░█▀█░█▄█
# ░█░█░█░█░█▄█░█▀█░█░░░█░█░█░█
# ░▀▀░░▀░▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀
# --------------------------------------------------------------------
# author: NFVblog aka Nicola Ferru <ask dot nfvblog at outlook dot it>
PAD=$(xsetwacom --list devices | awk '/PAD/||/pad/||/Pad/' | awk -F "id:" '{print $1}' | cut -d " " -f1-8 | sed -e 's/[[:space:]]*$//')
STYLUS=$(xsetwacom --list devices | awk '/STYLUS/||/stylus/||/Stylus/' | awk -F "id:" '{print $1}' | cut -d " " -f1-8 | sed -e 's/[[:space:]]*$//')
MONITORS=$(xrandr --listmonitors | awk '{print $2}' | grep - | sed 's/+//' | sed 's/*//')
PROFILE_DIR="./profiles"
# PROFILE_DIR="/usr/local/bin/profiles" # for global install
# driver compensations
compensation=7
gap=4
if [[ $1 == --version ]] || [[ $1 == -v ]] || [[ $1 == -VERSION ]]; then
cat << 'EOF'
╺┳┓┏┳┓┏━╸┏┓╻╻ ╻╻ ╻┏━┓┏━╸┏━┓┏┳┓ ┏━┓ ╻ ╻ ┏┓ ┏━╸╺┳╸┏━┓
┃┃┃┃┃┣╸ ┃┗┫┃ ┃┃╻┃┣━┫┃ ┃ ┃┃┃┃ ┃┃┃ ┗━┫ ┣┻┓┣╸ ┃ ┣━┫
╺┻┛╹ ╹┗━╸╹ ╹┗━┛┗┻┛╹ ╹┗━╸┗━┛╹ ╹ ┗━┛╹ ╹ ┗━┛┗━╸ ╹ ╹ ╹
EOF
exit 0
fi
if [[ $PAD == "" ]]; then
notify-send "💀 Pad not found"
exit 1
fi
if [[ $1 == --clear ]] || [[ $1 == -c ]] || [[ $1 == -CLEAR ]]; then
echo "" > dmw_history
exit 0
fi
ScreenLocking(){
launcher_app=$(echo "$MONITORS" | dmenu -i -p "Select display: ")
xinput map-to-output "$STYLUS" $launcher_app
notify-send "lock in $launcher_app"
}
ScreenRotation(){
rotate="left\nright\nnormal"
launcher_app=$(echo "$rotate" | dmenu -i -p "Select the direction of rotation: ")
case $launcher_app in
"left")
xinput set-prop "$STYLUS" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1;;
"right")
xinput set-prop "$STYLUS" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1;;
"normal")
xinput set-prop "$STYLUS" --type=float "Coordinate Transformation Matrix" 0 0 0 0 0 0 0 0 0;;
esac
}
Application_profiles() {
if [[ $PAD != "Wacom Intuos S Pad pad" ]] && [[ $PAD != "Wacom Intuos M Pad pad" ]] && [[ $PAD != "TABLET Pen Tablet Pad pad" ]];then
notify-send "💀 Pad not supported"
exit 1
fi
app=$(ls profiles | grep .dmwa | sed 's/.dmwa//')
launcher_app=$(echo "$app" | dmenu -i -p "Application profiles: ")
echo $launcher_app
$PROFILE_DIR/$launcher_app.dmwa "$PAD"
}
Button_setting() {
nbut=$(xsetwacom -s get "$PAD" all | grep "Button" | wc -l)
for number in {1..$nbut}
do
buttons+="$number\n"
done
launcher_button=$(echo "$buttons" | dmenu -i -p "Button: ")
if [[ $launcher_button < "0" ]] || [[ $launcher_button > $nbut ]];then
notify-send "the value is not included"
exit -1
fi
if [[ $launcher_button > "3" ]]; then
launcher_button=$(($launcher_button+$gap))
Button_set $launcher_button
elif [[ $launcher_button < $nbut ]]; then
Button_set $launcher_button
fi
}
Button_set(){
tmp=$(cat dmw_history)
if [[ $1 > $compensation ]]; then
nbut=$(($1-$gap))
launcher_but=$(echo "" | dmenu -i -p "Function $nbut: ")
else
launcher_but=$(echo "$tmp\n" | dmenu -i -p "Function $1: ")
fi
xsetwacom set "$PAD" Button $1 key $launcher_but
echo "$launcher_but" >> dmw_history
}
Info_tablet(){
notify-send " $PAD"
}
# launcher
wacom="Button setting\nApplication profiles\nScreen Locking\nRotate Pad\nInfo\nManual\n"
launcher_wacom=$(echo "$wacom" | dmenu -i -p "dmenuWacom")
[[ "$launcher_wacom" = "" ]] && exit 1
case $launcher_wacom in
"Button setting") Button_setting;;
"Application profiles") Application_profiles;;
"Screen Locking") ScreenLocking;;
"Rotate Pad") ScreenRotation;;
"Info") Info_tablet;;
"Manual") $TERM -e man dmenuWacom;;
esac