-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevent_loader
executable file
·68 lines (57 loc) · 2.28 KB
/
event_loader
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
#!/usr/bin/env sh
EVENT_HANDLER="$(dirname "$0")/event_handler"
# Load the default (empty) event implementations
. "$EVENT_HANDLER"
PFS=$IFS
load_events() {
IFS=$PFS
for f in $event_files; do
if . "$f"; then
printf >&2 'loaded event file: %s\n' "$f"
else
printf >&2 'failed sourcing event file: %s\n' "$f"
exit 2
fi
done
}
verbose=
case "$1" in
-v) verbose=1 && shift ;;
esac
event_files="$*"
load_events
trap 'load_events; continue' USR1
while true; do
if read -r event_data; then
event="${event_data%%>>*}"
edata="${event_data#"$event">>}"
IFS=','
set -- "$edata"
IFS=$PFS
if [ -n "$verbose" ]; then
printf >&2 '[%s] 1:%s 2:%s 3:%s 4:%s\n' "$event" "$1" "$2" "$3" "$4"
fi
case "$event" in
"activelayout") KEYBOARDNAME="$1" LAYOUTNAME="$2" event_activelayout ;;
"activewindow") WINDOWCLASS="$1" WINDOWTITLE="$2" event_activewindow ;;
"activewindowv2") WINDOWADDRESS="$1" event_activewindowv2 ;;
"closelayer") NAMESPACE="$1" event_closelayer ;;
"closewindow") WINDOWADDRESS="$1" event_closewindow ;;
"createworkspace") WORKSPACENAME="$1" event_createworkspace ;;
"destroyworkspace") WORKSPACENAME="$1" event_destroyworkspace ;;
"focusedmon") MONNAME="$1" WORKSPACENAME="$2" event_focusedmon ;;
"fullscreen") ENTER="$1" event_fullscreen ;;
"monitoradded") MONITORNAME="$1" event_monitoradded ;;
"monitorremoved") MONITORNAME="$1" event_monitorremoved ;;
"movewindow") WINDOWADDRESS="$1" WORKSPACENAME="$2" event_movewindow ;;
"moveworkspace") WORKSPACENAME="$1" MONNAME="$2" event_moveworkspace ;;
"openlayer") NAMESPACE="$1" event_openlayer ;;
"openwindow") WINDOWADDRESS="$1" WORKSPACENAME="$2" WINDOWCLASS="$3" WINDOWTITLE="$4" event_openwindow ;;
"screencast") STATE="$1" OWNER="$2" event_screencast ;;
"submap") SUBMAPNAME="$1" event_submap ;;
"windowtitle") WINDOWADDRESS="$1" event_windowtitle ;;
"workspace") WORKSPACENAME="$1" event_workspace ;;
*) printf >&2 'Unknown event: %s\n' "$event" ;;
esac
fi
done