From fe9ce9b699f1e1ffc6b7fd77b5d2d462b70b1b14 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Mon, 28 Oct 2024 23:46:41 +1000 Subject: Move the "decide which card" bit to "start". --- aataaj.lua | 61 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'aataaj.lua') diff --git a/aataaj.lua b/aataaj.lua index 9acea95..9df7635 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -180,42 +180,41 @@ print('') io.flush() -print('Your ' .. cnt .. ' audio devices are ') -for k,C in pairs(Cards) do - print('' .. C.card - 1 .. ' : ' .. C.name) - __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Your ' .. cnt .. ' audio devices are "'):log():noErr():noOut():fork() -end --- TODO - should do a proper "wait for speakers to finish" here. Have fork(write a file), think that's what :wait(file) does. -__'sleep 6':Do() -print('') -io.flush() -for k,C in pairs(Cards) do - print('' .. C.card - 1 .. ' : ' .. C.name) - __('echo "' .. C.card - 1 .. ' : ' .. C.name .. '"') - __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Device number ' .. C.card - 1 .. ' ' .. C.name .. '"'):log():noErr():noOut():Do() +if 'start' == arg[1] then + print('Your ' .. cnt .. ' audio devices are ') + for k,C in pairs(Cards) do + print('' .. C.card - 1 .. ' : ' .. C.name) + __ ('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Your ' .. cnt .. ' audio devices are "'):log():noErr():noOut():fork() + end + -- TODO - should do a proper "wait for speakers to finish" here. Have fork(write a file), think that's what :wait(file) does. + __'sleep 6':Do() + print('') + io.flush() + for k,C in pairs(Cards) do + print('' .. C.card - 1 .. ' : ' .. C.name) + __('echo "' .. C.card - 1 .. ' : ' .. C.name .. '"') + __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Device number ' .. C.card - 1 .. ' ' .. C.name .. '"'):log():noErr():noOut():Do() + io.flush() + __'sleep 1':Do() + end + print('') io.flush() - __'sleep 1':Do() -end -print('') -io.flush() -for k,C in pairs(Cards) do - print('' .. C.card - 1 .. ' : ' .. C.name) - __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Please type the device number you heard best."'):log():noErr():noOut():fork() -end -io.write('Please type the device number you heard best - ') -local choice = tonumber(io.read()) -- Lua has no way of just checking IF there is ANY input, so can't do "check if there was a keypress, continue if not". -local ourCard = '' - -for k,C in pairs(Cards) do - if (C.card - 1) == choice then - print('You choose ' .. choice .. ' ' .. C.name) - ourCard = C.name + for k,C in pairs(Cards) do + print('' .. C.card - 1 .. ' : ' .. C.name) + __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Please type the device number you heard best."'):log():noErr():noOut():fork() end -end + io.write('Please type the device number you heard best - ') + local choice = tonumber(io.read()) -- Lua has no way of just checking IF there is ANY input, so can't do "check if there was a keypress, continue if not". + local ourCard = '' + for k,C in pairs(Cards) do + if (C.card - 1) == choice then + print('You choose ' .. choice .. ' ' .. C.name) + ourCard = C.name + end + end -if 'start' == arg[1] then __('mkdir -p ' .. options.asoundrcPath.value):Do() local a, e = io.open(options.asoundrcPath.value .. '/jack-plumbing', 'w') if nil == a then print('Could not open ' .. options.asoundrcPath.value .. '/jack-plumbing - ' .. e) else -- cgit v1.1