-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_lr_main_latest.sh
executable file
·160 lines (136 loc) · 3.98 KB
/
run_lr_main_latest.sh
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
source=microphone
run_left=0
run_right=0
run_manual_controlled=1
kill_needed=0
pids_to_kill=()
function find_window() {
name="$1"
class="$2"
comm -12 \
<(xdotool search --name "$name" | sort -u) \
<(xdotool search --class "$class" | sort -u)
}
function handle_term() {
for pid in ${pids_to_kill[*]}; do
echo "Killing $pid children..."
for child_pid in "$(ps -o pid --no-headers --ppid ${pid})"; do
if [[ -z $child_pid ]]; then
continue
fi
echo "Killing child $child_pid"
kill -9 $child_pid
done
echo "Killing $pid"
kill -9 $pid
done
}
# function wait_term() {
# if [[ "${kill_needed}" == 1 ]]; then
# for pid in ${pids_to_kill[*]}; do
# kill $pid 2> /dev/null
# done
# fi
# trap - TERM INT
# for pid in ${pids_to_kill[*]}; do
# wait $pid
# done
# }
if [[ $run_left == 1 ]]; then
SDL_VIDEO_X11_WMCLASS=left_eye ./run_libopendrop.sh \
-s $source \
--nodraw_signal_viewer \
--control_state=$(pwd)/configs/kaleidoscope_config.textproto \
--control_port=9955 \
--inject &
pids_to_kill+="$! "
fi
if [[ $run_right == 1 ]]; then
SDL_VIDEO_X11_WMCLASS=right_eye ./run_libopendrop.sh \
-s $source \
--nodraw_signal_viewer \
--control_state=$(pwd)/configs/kaleidoscope_config.textproto \
--control_port=9945 \
--inject &
pids_to_kill+="$! "
fi
if [[ $run_manual_controlled == 1 ]]; then
SDL_VIDEO_X11_WMCLASS=left_main ./run_libopendrop.sh \
-s $source \
--inject \
--control_state=$(pwd)/configs/mpk_mini_config.textproto \
--control_port=9964 &
pids_to_kill+="$! "
SDL_VIDEO_X11_WMCLASS=right_main ./run_libopendrop.sh \
-s $source \
--inject \
--control_state=$(pwd)/configs/mpk_mini_config.textproto \
--control_port=9965 &
pids_to_kill+="$! "
fi
if [[ $run_left == 1 ]] || [[ $run_right == 1 ]]; then
./binaries/control_sender.par --input_filter='.*Feather.*' --ports=9955 --ports=9945 &
pids_to_kill+="$! "
fi
if [[ $run_left == 1 ]] || [[ $run_right == 1 ]] || [[ $run_manual_controlled == 1 ]]; then
./binaries/control_sender.par --input_filter='.*MPK.*' --ports=9944 --ports=9965 --ports=9965 --ports=9988 &
pids_to_kill+="$! "
fi
if [[ $run_left == 1 ]]; then
while [[ -z $(xdotool search --class "left_eye") ]]; do
echo "Waiting for left_eye"
sleep 1
done
fi
if [[ $run_right == 1 ]]; then
while [[ -z $(xdotool search --class "right_eye") ]]; do
echo "Waiting for right_eye"
sleep 1
done
fi
if [[ $run_manual_controlled == 1 ]]; then
while [[ -z $(xdotool search --class "left_main") ]]; do
echo "Waiting for left_main"
sleep 1
done
while [[ -z $(xdotool search --class "right_main") ]]; do
echo "Waiting for right_main"
sleep 1
done
fi
sleep 2
if [[ $run_left == 1 ]]; then
LEFT_WINDOW_ID=$(find_window "OpenDrop Visualizer View" "left_eye")
fi
if [[ $run_right == 1 ]]; then
RIGHT_WINDOW_ID=$(find_window "OpenDrop Visualizer View" "right_eye")
fi
if [[ $run_manual_controlled == 1 ]]; then
MANUAL_L_WINDOW_ID=$(find_window "OpenDrop Visualizer View" "left_main")
MANUAL_R_WINDOW_ID=$(find_window "OpenDrop Visualizer View" "right_main")
fi
echo $LEFT_WINDOW_ID $RIGHT_WINDOW_ID $MANUAL_WINDOW_ID
if [[ $run_manual_controlled == 1 ]]; then
i3-msg "[id=\"$MANUAL_L_WINDOW_ID\"] move container to output DP-0.1"
i3-msg "[id=\"$MANUAL_L_WINDOW_ID\"] fullscreen enable"
i3-msg "[id=\"$MANUAL_R_WINDOW_ID\"] move container to output DP-0.2"
i3-msg "[id=\"$MANUAL_R_WINDOW_ID\"] fullscreen enable"
fi
if [[ $run_left == 1 ]]; then
sleep 2
i3-msg "[id=\"$LEFT_WINDOW_ID\"] move container to output DP-0.1"
i3-msg "[id=\"$LEFT_WINDOW_ID\"] fullscreen enable"
fi
if [[ $run_right == 1 ]]; then
sleep 2
i3-msg "[id=\"$RIGHT_WINDOW_ID\"] move container to output DP-0.2"
i3-msg "[id=\"$RIGHT_WINDOW_ID\"] fullscreen enable"
fi
echo "Pids to kill: ${pids_to_kill[@]}"
trap 'handle_term' TERM INT
for pid in ${pids_to_kill[*]}; do
wait $pid
done
#wait_term
echo "Done, exiting"