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
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env sh
ACTION="$1"
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
XPROPOUT="$(xprop -id "$(xdotool getactivewindow)")"
WMCLASS="$(echo "$XPROPOUT" | grep WM_CLASS | cut -d ' ' -f3- | cut -d ' ' -f1 | tr -d '\",')"
HANDLE=1
if [ -x "$XDG_CONFIG_HOME"/sxmo/hooks/gesture ]; then
#hook script must exit with a zero exit code ONLY if it has handled the gesture!
"$XDG_CONFIG_HOME"/sxmo/hooks/gesture "$WMCLASS" "$@"
HANDLE=$?
fi
if [ "$HANDLE" -ne 0 ]; then
#special context-sensitive handling
case "$WMCLASS" in
"foxtrotgps")
# E.g. just a check to ignore 1-finger gestures in foxtrotgps
if [ "$ACTION" != "killwindow" ]; then
HANDLE=0
fi
;;
"st-256color")
# First we try to handle the app running inside st:
WMNAME=$(echo "$XPROPOUT" | grep -E "^WM_NAME" | cut -d ' ' -f3-)
if echo "$WMNAME" | grep -i -w tuir; then
if [ "$ACTION" = "enter" ]; then
xdotool key o
HANDLE=0
elif [ "$ACTION" = "back" ]; then
xdotool key s
HANDLE=0
fi
fi
;;
esac
fi
if [ "$HANDLE" -ne 0 ]; then
#standard handling
case "$ACTION" in
"prevdesktop")
xdotool key --clearmodifiers Alt+Shift+e
;;
"nextdesktop")
xdotool key --clearmodifiers Alt+Shift+r
;;
"moveprevdesktop")
xdotool key --clearmodifiers Alt+e
;;
"movenextdesktop")
xdotool key --clearmodifiers Alt+r
;;
"unmute")
sxmo_vol.sh unmute &
;;
"mute")
sxmo_vol.sh mute &
;;
"brightnessup")
sxmo_brightness.sh up &
;;
"brightnessdown")
sxmo_brightness.sh down &
;;
"volup")
sxmo_vol.sh up &
;;
"voldown")
sxmo_vol.sh down &
;;
"showkeyboard")
sxmo_keyboard.sh open
;;
"hidekeyboard")
sxmo_keyboard.sh close
;;
"showmenu")
pidof dmenu || setsid -f sxmo_appmenu.sh &
;;
"showsysmenu")
pidof dmenu || setsid -f sxmo_appmenu.sh sys &
;;
"hidemenu")
pkill -9 dmenu
;;
"closewindow")
sxmo_killwindow.sh close
;;
"killwindow")
sxmo_killwindow.sh
;;
"scrollup_long")
xdotool key Prior
;;
"scrolldown_long")
xdotool key Next
;;
"scrollup_med")
xdotool key Up Up Up
;;
"scrolldown_med")
xdotool key Down Down Down
;;
"scrollup_short")
xdotool key Up
;;
"scrolldown_short")
xdotool key Down
;;
"scrollleft_short")
xdotool key Left
;;
"scrollright_short")
xdotool key Right
;;
"enter")
xdotool key Return
;;
"back")
xdotool key BackSpace
;;
*)
#fallback, just execute the command
"$@"
;;
esac
fi