aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordvs12024-10-24 13:28:18 +1000
committerdvs12024-10-24 13:28:18 +1000
commite4fcdb2458635ca3c034fcd2df129f53d9e154e5 (patch)
treedaa0ed1e8fe1b87b231c744ee039c9649b4861c6
parentSplit up the audio output a little nicer. (diff)
downloadJackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.zip
JackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.tar.gz
JackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.tar.bz2
JackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.tar.xz
Some more tidying up.
-rwxr-xr-x_.lua71
-rwxr-xr-xaataaj.lua59
-rwxr-xr-xtest_.lua38
3 files changed, 30 insertions, 138 deletions
diff --git a/_.lua b/_.lua
index f5ab5b9..33b4183 100755
--- a/_.lua
+++ b/_.lua
@@ -45,7 +45,7 @@ _.parseArgs = function(options, args)
45 if nil == o then 45 if nil == o then
46 local h = '' 46 local h = ''
47 for k, v in pairs(options) do 47 for k, v in pairs(options) do
48 h = h .. k .. '|' 48 h = h .. k .. ' | '
49 end 49 end
50 print('Usage: aataaj.lua {' .. string.sub(h, 1, -2) .. '}') 50 print('Usage: aataaj.lua {' .. string.sub(h, 1, -2) .. '}')
51 os.exit(0) 51 os.exit(0)
@@ -62,9 +62,10 @@ end
62 62
63_.exists = function(f) 63_.exists = function(f)
64 local h, e = io.open(f, "r") 64 local h, e = io.open(f, "r")
65 if nil == h then return false else h:close(); return true end 65 if nil == h then return false else h:close(); return true end
66end 66end
67 67
68
68_.killEmAll = function(all) 69_.killEmAll = function(all)
69 for i,l in ipairs(all) do 70 for i,l in ipairs(all) do
70 local c = 0 71 local c = 0
@@ -91,6 +92,7 @@ _.readCmd = function(cmd)
91 return result 92 return result
92end 93end
93 94
95
94__ = function(c) 96__ = function(c)
95 local exe = {status = 0, lines = {}, logging = false, showing = false, cmd = '', command = c, isScript = false, script = ''} 97 local exe = {status = 0, lines = {}, logging = false, showing = false, cmd = '', command = c, isScript = false, script = ''}
96 local n = 0 98 local n = 0
@@ -130,15 +132,6 @@ __ = function(c)
130 exe.cmd = exe.cmd .. ' } ' 132 exe.cmd = exe.cmd .. ' } '
131 if 1 == n then exe.cmd = c end 133 if 1 == n then exe.cmd = c end
132 134
133 function exe:log()
134 self.logging = true
135 return self
136 end
137
138 function exe:show()
139 self.showing = true
140 return self
141 end
142 135
143 function exe:Nice(c) 136 function exe:Nice(c)
144 if nil == c then 137 if nil == c then
@@ -160,38 +153,15 @@ __ = function(c)
160 return self 153 return self
161 end 154 end
162 155
163 function exe:also(c) -- Should be called "then" but that's a reserved word. 156 function exe:log() self.logging = true return self end
164 if nil == c then c = '' else c = ' ' .. c end 157 function exe:show() self.showing = true return self end
165 self.cmd = self.cmd .. '; ' .. c .. ' ' 158 -- Should be called "then" but that's a reserved word.
166 return self 159 function exe:also(c) if nil == c then c = '' else c = ' ' .. c end self.cmd = self.cmd .. '; ' .. c .. ' ' return self end
167 end 160 function exe:And(c) if nil == c then c = '' else c = ' ' .. c end self.cmd = self.cmd .. ' && ' .. c .. ' ' return self end
168 161 function exe:Or(c) if nil == c then c = '' else c = ' ' .. c end self.cmd = self.cmd .. ' || ' .. c .. ' ' return self end
169 function exe:And(c) 162 function exe:noErr() self.cmd = self.cmd .. ' 2>/dev/null ' return self end
170 if nil == c then c = '' else c = ' ' .. c end 163 function exe:noOut() self.cmd = self.cmd .. ' 1>/dev/null ' return self end
171 self.cmd = self.cmd .. ' && ' .. c .. ' ' 164 function exe:wait(w) self.cmd = self.cmd .. ' && touch ' .. w .. ' ' return self end
172 return self
173 end
174
175 function exe:Or(c)
176 if nil == c then c = '' end
177 self.cmd = self.cmd .. ' || ' .. c .. ' '
178 return self
179 end
180
181 function exe:noErr()
182 self.cmd = self.cmd .. ' 2>/dev/null '
183 return self
184 end
185
186 function exe:noOut()
187 self.cmd = self.cmd .. ' 1>/dev/null '
188 return self
189 end
190
191 function exe:wait(w)
192 self.cmd = self.cmd .. ' && touch ' .. w .. ' '
193 return self
194 end
195 165
196 function exe:Do() 166 function exe:Do()
197 --[[ "The condition expression of a control structure can return any 167 --[[ "The condition expression of a control structure can return any
@@ -207,17 +177,16 @@ __ = function(c)
207 local ok, rslt, status = os.execute(s) 177 local ok, rslt, status = os.execute(s)
208 ]] 178 ]]
209 self.lines = _.readCmd(self.cmd .. '; echo "$?"', 'r') 179 self.lines = _.readCmd(self.cmd .. '; echo "$?"', 'r')
210 -- The last line will be the command's returned status, collect everything else in lines. 180 -- The last line will be the command's returned status, fish that out and collect everything else in lines.
211 self.status = tonumber(self.lines[#self.lines]) 181 self.status = tonumber(self.lines[#self.lines])
212 self.lines[#self.lines] = nil 182 self.lines[#self.lines] = nil
213 if true == self.showing then for i, l in ipairs(self.lines) do D(l) end end 183 if true == self.showing then for i, l in ipairs(self.lines) do I(l) end end
214 if (137 == self.status) or (124 == self.status) then 184
215 T("timeout killed " .. self.status .. ' ' .. self.command) 185 if (nil == self.status) then D("STATUS |" .. "NIL" .. '| ' .. self.command)
216 elseif (nil == self.status) then 186 elseif (137 == self.status) or (124 == self.status) then T("timeout killed " .. self.status .. ' ' .. self.command)
217 D("STATUS |" .. "NIL" .. '| ' .. self.command) 187 elseif (0 ~= self.status) then D("STATUS |" .. self.status .. '| ' .. self.command)
218 elseif (0 ~= self.status) then
219 D("STATUS |" .. self.status .. '| ' .. self.command)
220 end 188 end
189
221 return self 190 return self
222 end 191 end
223 192
diff --git a/aataaj.lua b/aataaj.lua
index e7bb492..06077c2 100755
--- a/aataaj.lua
+++ b/aataaj.lua
@@ -17,7 +17,6 @@
17local _ = require '_' 17local _ = require '_'
18 18
19 19
20
21local Help = [[ 20local Help = [[
22This is part of the AllAudioToALSAandJACK project, aataaj for short, 21This is part of the AllAudioToALSAandJACK project, aataaj for short,
23pronounced like "attach". 22pronounced like "attach".
@@ -149,64 +148,6 @@ _.parseArgs(options, args)
149 148
150 149
151 150
152
153
154
155--[=[
156local args = {...}
157if 0 ~= #args then
158-- for i,a in pairs(args) do
159-- print('Argument ' .. i .. ' = ' .. a)
160-- end
161
162 if 'start' == args[1] then
163 elseif 'stop' == args[1] then
164 elseif 'STOP' == args[1] then
165 _.killEmAll{'qsynth'}
166 __[[
167 a2j_control --stop
168 sleep 2
169 a2j_control --exit
170 sleep 2
171]]:Do()
172 _.killEmAll{'alsa_in', 'alsa_out', 'zita-a2j', 'zita-j2a', 'aseqjoy', 'jack-plumbing'}
173 __[[
174 sleep 2
175 jack_control stop
176 sleep 2
177 jack_control exit
178 sleep 2
179]]:Do()
180 _.killEmAll{'jmcore', 'qjackctl'}
181 -- Catia is python, and no easy way to kill it.
182 -- Also it keeps jackdbus alive, no matter how hard you kill it.
183 __"pkill -TERM -u $USER -f catia":Do()
184 __"sleep 2":Do()
185 _.killEmAll{'jackdbus', 'a2jmidid'}
186 return(0)
187 elseif 'JACK' == args[1] then
188 elseif 'restart' == args[1] then args[1] = 'start'
189 elseif 'force-reload' == args[1] then args[1] = 'start'
190 elseif 'status' == args[1] then
191 return(0)
192 elseif 'help' == args[1] then
193 print(Help)
194 return(0)
195 elseif '--help' == args[1] then
196 print(Help)
197 return(0)
198 else
199 print("Usage: aataaj.lua {start|stop|restart|force-reload|status|JACK|STOP}")
200 return(1)
201 end
202else
203 print("Usage: aataaj.lua {help|start|stop|restart|force-reload|status|JACK|STOP}")
204 return(1)
205end
206]=]
207
208
209
210-- CHANGE these to suit. 151-- CHANGE these to suit.
211local asoundrcPath = '/var/lib/aataaj' 152local asoundrcPath = '/var/lib/aataaj'
212local asoundrc = 'asoundrc' 153local asoundrc = 'asoundrc'
diff --git a/test_.lua b/test_.lua
index 497b896..e559238 100755
--- a/test_.lua
+++ b/test_.lua
@@ -13,27 +13,13 @@ This is part of the blah blah blah...
13 13
14local options = 14local options =
15{ 15{
16 start = 16 start = {help = 'Command to start the scanning process, for Sys V init.',},
17 {
18 help = 'Command to start the scanning process, for Sys V init.',
19 },
20 restart = {start}, 17 restart = {start},
21 ['force-reload'] = {start}, 18 ['force-reload'] = {start},
22 status = 19 status = {help = 'Command to check the status of the scanning process, for Sys V init.',},
23 { 20 stop = {help = 'Command to stop the scanning process, for Sys V init.',},
24 help = 'Command to check the status of the scanning process, for Sys V init.', 21 JACK = {help = 'Command to start the JACK stuff, for users.',},
25 }, 22 STOP = {help = 'Command to stop the JACK stuff, for users.',
26 stop =
27 {
28 help = 'Command to stop the scanning process, for Sys V init.',
29 },
30 JACK =
31 {
32 help = 'Command to start the JACK stuff, for users.',
33 },
34 STOP =
35 {
36 help = 'Command to stop the JACK stuff, for users.',
37 func = function(a, args, i) 23 func = function(a, args, i)
38--[=[ 24--[=[
39 _.killEmAll{'qsynth'} 25 _.killEmAll{'qsynth'}
@@ -60,9 +46,7 @@ local options =
60]=] 46]=]
61 end 47 end
62 }, 48 },
63 help = 49 help = {help = 'Print help.',
64 {
65 help = 'Print help.',
66 func = function(a, args, i) 50 func = function(a, args, i)
67 print(Help) 51 print(Help)
68 os.exit(0) 52 os.exit(0)
@@ -96,17 +80,15 @@ for i,l in ipairs(__'free -h':log():Do().lines) do
96end 80end
97print('') 81print('')
98 82
99__'uname -a':log():also'free -h':show():Do()
100print('')
101
102for i,l in ipairs(__'uname -a\nfree -h':log():Do().lines) do 83for i,l in ipairs(__'uname -a\nfree -h':log():Do().lines) do
103 print(l) 84 print(l)
104end 85end
105print('') 86print('')
106 87
107for i,l in ipairs(__{'uname -a', 'free -h'}:log():Do().lines) do 88__'uname -a':log():also'free -h':show():Do()
108 print(l) 89print('')
109end 90
91__{'uname -a', 'free -h'}:log():show():Do()
110print('') 92print('')
111 93
112 94