diff options
Diffstat (limited to 'aataaj.lua')
-rwxr-xr-x | aataaj.lua | 49 |
1 files changed, 22 insertions, 27 deletions
@@ -24,7 +24,7 @@ joysticks it finds as MIDI controllers. So any ALSA application gets routed thr | |||
24 | JACK. | 24 | JACK. |
25 | 25 | ||
26 | This is very rough for now, only just started writing it. The stop | 26 | This is very rough for now, only just started writing it. The stop |
27 | command is particularly crude and violent, lots of killall. | 27 | command is particularly crude and violent, lots of pkill. |
28 | 28 | ||
29 | Since it isn't a package yet, some setup is needed. | 29 | Since it isn't a package yet, some setup is needed. |
30 | 30 | ||
@@ -190,6 +190,19 @@ APT.exe = function(c) | |||
190 | return exe | 190 | return exe |
191 | end | 191 | end |
192 | 192 | ||
193 | APT.killEmAll = function(all) | ||
194 | for i,l in ipairs(all) do | ||
195 | local c = 0 | ||
196 | while 0 ~= tonumber(APT.exe("pgrep -u $USER -xc " .. l):Do().result) do | ||
197 | local s = 'TERM' | ||
198 | if c > 0 then s = 'KILL' end | ||
199 | print( "pkill -" .. s .. " -u $USER -x " .. l) | ||
200 | APT.exe("pkill -" .. s .. " -u $USER -x " .. l):Do() | ||
201 | c = c + 1 | ||
202 | end | ||
203 | end | ||
204 | end | ||
205 | |||
193 | 206 | ||
194 | 207 | ||
195 | local args = {...} | 208 | local args = {...} |
@@ -200,17 +213,12 @@ if 0 ~= #args then | |||
200 | 213 | ||
201 | if 'start' == args[1] then | 214 | if 'start' == args[1] then |
202 | elseif 'stop' == args[1] then | 215 | elseif 'stop' == args[1] then |
203 | APT.exe("killall -TERM qsynth"):Do() | 216 | APT.killEmAll{'qsynth'} |
204 | APT.exe("a2j_control --stop"):Do() | 217 | APT.exe("a2j_control --stop"):Do() |
205 | APT.exe("sleep 2"):Do() | 218 | APT.exe("sleep 2"):Do() |
206 | APT.exe("a2j_control --exit"):Do() | 219 | APT.exe("a2j_control --exit"):Do() |
207 | APT.exe("sleep 2"):Do() | 220 | APT.exe("sleep 2"):Do() |
208 | APT.exe("killall -TERM alsa_out"):Do() | 221 | APT.killEmAll{'alsa_in', 'alsa_out', 'zita-a2j', 'zita-j2a', 'aseqjoy', 'jack-plumbing'} |
209 | APT.exe("killall -TERM alsa_in"):Do() | ||
210 | APT.exe("killall -TERM zita-a2j"):Do() | ||
211 | APT.exe("killall -TERM zita-j2a"):Do() | ||
212 | APT.exe("killall -TERM aseqjoy"):Do() | ||
213 | APT.exe("killall -TERM jack-plumbing"):Do() | ||
214 | APT.exe("sleep 2"):Do() | 222 | APT.exe("sleep 2"):Do() |
215 | APT.exe("jack_control stop"):Do() | 223 | APT.exe("jack_control stop"):Do() |
216 | APT.exe("sleep 2"):Do() | 224 | APT.exe("sleep 2"):Do() |
@@ -218,25 +226,12 @@ if 0 ~= #args then | |||
218 | APT.exe("sleep 2"):Do() | 226 | APT.exe("sleep 2"):Do() |
219 | --APT.exe("a2j_control --stop; a2j_control --exit"):Do() | 227 | --APT.exe("a2j_control --stop; a2j_control --exit"):Do() |
220 | --APT.exe("sleep 2"):Do() | 228 | --APT.exe("sleep 2"):Do() |
221 | APT.exe("killall -TERM jmcore"):Do() | 229 | APT.killEmAll{'jmcore', 'qjackctl'} |
222 | APT.exe("pkill -TERM jackdbus; pkill -TERM a2jmidid"):Do() | ||
223 | APT.exe("killall -TERM a2jmidid"):Do() | ||
224 | APT.exe("killall -KILL jackdbus"):Do() | ||
225 | APT.exe("sleep 2"):Do() | ||
226 | APT.exe("killall -KILL a2jmidid"):Do() | ||
227 | APT.exe("pkill -KILL jackdbus; pkill -KILL a2jmidid"):Do() | ||
228 | APT.exe("sleep 2"):Do() | ||
229 | APT.exe("killall -KILL a2jmidid"):Do() | ||
230 | APT.exe("killall -KILL jackdbus"):Do() | ||
231 | APT.exe("sleep 2"):Do() | ||
232 | APT.exe("killall -KILL a2jmidid"):Do() | ||
233 | APT.exe("killall -KILL jackdbus"):Do() | ||
234 | APT.exe("sleep 2"):Do() | ||
235 | APT.exe("pkill -KILL jackdbus; pkill -KILL a2jmidid"):Do() | ||
236 | APT.exe("killall -TERM qjackctl"):Do() | ||
237 | |||
238 | -- Catia is python, and no easy way to kill it. | 230 | -- Catia is python, and no easy way to kill it. |
239 | APT.exe("ps auxw | grep python"):Do() | 231 | -- Also it keeps jackdbus alive, no matter how hard you kill it. |
232 | APT.exe("pkill -TERM -u $USER -f catia"):Do() | ||
233 | APT.exe("sleep 2"):Do() | ||
234 | APT.killEmAll{'jackdbus', 'a2jmidid'} | ||
240 | return(0) | 235 | return(0) |
241 | elseif 'JACK' == args[1] then | 236 | elseif 'JACK' == args[1] then |
242 | elseif 'restart' == args[1] then args[1] = 'start' | 237 | elseif 'restart' == args[1] then args[1] = 'start' |
@@ -564,5 +559,5 @@ elseif 'JACK' == args[1] then | |||
564 | 559 | ||
565 | print('Stop our jack-plumbing, eventually.') | 560 | print('Stop our jack-plumbing, eventually.') |
566 | APT.exe('sleep 4'):Do() | 561 | APT.exe('sleep 4'):Do() |
567 | APT.exe("killall -TERM jack-plumbing"):Do() | 562 | APT.killEmAll("jack-plumbing"):Do() |
568 | end | 563 | end |