diff options
author | dvs1 | 2024-10-24 13:28:18 +1000 |
---|---|---|
committer | dvs1 | 2024-10-24 13:28:18 +1000 |
commit | e4fcdb2458635ca3c034fcd2df129f53d9e154e5 (patch) | |
tree | daa0ed1e8fe1b87b231c744ee039c9649b4861c6 | |
parent | Split up the audio output a little nicer. (diff) | |
download | JackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.zip JackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.tar.gz JackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.tar.bz2 JackOnAllDevices-e4fcdb2458635ca3c034fcd2df129f53d9e154e5.tar.xz |
Some more tidying up.
Diffstat (limited to '')
-rwxr-xr-x | _.lua | 71 | ||||
-rwxr-xr-x | aataaj.lua | 59 | ||||
-rwxr-xr-x | test_.lua | 38 |
3 files changed, 30 insertions, 138 deletions
@@ -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 |
66 | end | 66 | end |
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 |
92 | end | 93 | end |
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 | ||
@@ -17,7 +17,6 @@ | |||
17 | local _ = require '_' | 17 | local _ = require '_' |
18 | 18 | ||
19 | 19 | ||
20 | |||
21 | local Help = [[ | 20 | local Help = [[ |
22 | This is part of the AllAudioToALSAandJACK project, aataaj for short, | 21 | This is part of the AllAudioToALSAandJACK project, aataaj for short, |
23 | pronounced like "attach". | 22 | pronounced like "attach". |
@@ -149,64 +148,6 @@ _.parseArgs(options, args) | |||
149 | 148 | ||
150 | 149 | ||
151 | 150 | ||
152 | |||
153 | |||
154 | |||
155 | --[=[ | ||
156 | local args = {...} | ||
157 | if 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 | ||
202 | else | ||
203 | print("Usage: aataaj.lua {help|start|stop|restart|force-reload|status|JACK|STOP}") | ||
204 | return(1) | ||
205 | end | ||
206 | ]=] | ||
207 | |||
208 | |||
209 | |||
210 | -- CHANGE these to suit. | 151 | -- CHANGE these to suit. |
211 | local asoundrcPath = '/var/lib/aataaj' | 152 | local asoundrcPath = '/var/lib/aataaj' |
212 | local asoundrc = 'asoundrc' | 153 | local asoundrc = 'asoundrc' |
@@ -13,27 +13,13 @@ This is part of the blah blah blah... | |||
13 | 13 | ||
14 | local options = | 14 | local 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 | |||
96 | end | 80 | end |
97 | print('') | 81 | print('') |
98 | 82 | ||
99 | __'uname -a':log():also'free -h':show():Do() | ||
100 | print('') | ||
101 | |||
102 | for i,l in ipairs(__'uname -a\nfree -h':log():Do().lines) do | 83 | for i,l in ipairs(__'uname -a\nfree -h':log():Do().lines) do |
103 | print(l) | 84 | print(l) |
104 | end | 85 | end |
105 | print('') | 86 | print('') |
106 | 87 | ||
107 | for i,l in ipairs(__{'uname -a', 'free -h'}:log():Do().lines) do | 88 | __'uname -a':log():also'free -h':show():Do() |
108 | print(l) | 89 | print('') |
109 | end | 90 | |
91 | __{'uname -a', 'free -h'}:log():show():Do() | ||
110 | print('') | 92 | print('') |
111 | 93 | ||
112 | 94 | ||