From e4d51e4c5904895dd599d099e857ccebdf1714fc Mon Sep 17 00:00:00 2001 From: dvs1 Date: Tue, 22 Oct 2024 13:51:59 +1000 Subject: Lots of little tweaks about how _ works. --- aataaj.lua | 68 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) (limited to 'aataaj.lua') diff --git a/aataaj.lua b/aataaj.lua index a92e0fb..26db4d2 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -118,8 +118,8 @@ if 0 ~= #args then _.killEmAll{'jmcore', 'qjackctl'} -- Catia is python, and no easy way to kill it. -- Also it keeps jackdbus alive, no matter how hard you kill it. - __("pkill -TERM -u $USER -f catia"):Do() - __("sleep 2"):Do() + __"pkill -TERM -u $USER -f catia":Do() + __"sleep 2":Do() _.killEmAll{'jackdbus', 'a2jmidid'} return(0) elseif 'JACK' == args[1] then @@ -149,18 +149,18 @@ end local asoundrcPath = '/var/lib/aataaj' local asoundrc = 'asoundrc' local GUI = 'qjackctl' -if _.exists('catia') then GUI = 'catia' end +if _.runnable('catia') then GUI = 'catia' end local alias = { -- {name='Screen', dev='HDMI9'}, } local speaker = 'espeak' -if _.exists('espeak-ng') then speaker = 'espeak-ng' end +if _.runnable('espeak-ng') then speaker = 'espeak-ng' end local Cards = {} print('Scanning for audio devices.') -local cards = __('ls -d1 /proc/asound/card[0-9]*'):noErr():Do() +local cards = __'ls -d1 /proc/asound/card[0-9]*':noErr():Do() for i,l in ipairs(cards.lines) do local f, e = io.open(l .. '/id', "r") if nil == f then print("Could not open " .. l .. '/id') else @@ -182,7 +182,7 @@ for i,l in ipairs(cards.lines) do if 'JACK' ~= args[1] then print('\t\tALSA_CARD=' .. i - 1 .. ' ' .. speaker .. ' "Found playback device ' .. i - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"') __('ALSA_CARD=' .. i - 1 .. ' ' .. speaker .. ' "Found playback device ' .. i - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"'):noErr():Do() - __('sleep 1'):Do() + __'sleep 1':Do() end end end @@ -363,31 +363,29 @@ elseif 'JACK' == args[1] then print('') print("Start up JACK and friends.") print("jack_control") - __('jack_control start'):Do() - __('jack_control ds alsa'):Do() + __[[jack_control start + jack_control ds alsa]]:Do() --jack_control dps device hw:RIG,0 - local r = __('jack_control status'):Do().status - while r ~= 0 do - print("Waiting for JACK - sleep 1") - __('sleep 1'):Do() - r = __('jack_control status'):Do().status + while 0 ~= __'jack_control status':Do().status do + print("Waiting for JACK") + __'sleep 1':Do() end if nil ~= GUI then print(GUI) - __(GUI):fork() + __(GUI):forkOnce() end - if _.exists('jack-plumbing') then + if _.runnable'jack-plumbing' then print("jack-plumbing") - __('jack-plumbing -o /var/lib/aataaj/jack-plumbing 2>/dev/null'):fork() + __'jack-plumbing -o /var/lib/aataaj/jack-plumbing 2>/dev/null':fork() end - if _.exists('a2j_control') then + if _.runnable'a2j_control' then -- Bridge ALSA ports to JACK ports. Only handles MIDI. -- MIDI via a2jmidid. The --ehw enables hardware ports as well, equal to using the seq MIDI drivare according to https://freeshell.de/~murks/posts/ALSA_and_JACK_MIDI_explained_(by_a_dummy_for_dummies)/ --a2j_control actually starts a2jmidid. ----a2jmidid -e -u & -- I think the jack_control start and my current alsa config means a2jmidid gets started anyway. But seem to need this bit to get the joystick covered. print("a2j_control") - __('a2j_control --ehw && a2j_control --start'):Do() + __'a2j_control --ehw && a2j_control --start':Do() -- print("sleep 2") -- __('sleep 2'):Do() print("") @@ -395,9 +393,9 @@ elseif 'JACK' == args[1] then local AIN = "alsa_in" - if _.exists('zita-a2j') then AIN = 'zita-a2j' end + if _.runnable'zita-a2j' then AIN = 'zita-a2j' end local AOUT = "alsa_out" - if _.exists('zita-j2a') then AOUT = 'zita-j2a' end + if _.runnable'zita-j2a' then AOUT = 'zita-j2a' end print("Basic ALSA sound devices converted to JACK.") for i,C in pairs(alias) do @@ -406,15 +404,15 @@ elseif 'JACK' == args[1] then end print("HW playback: cloop\tDEVICE: cloop") -- No idea why, cloop wont work with zita-a2j. - __('alsa_in -j cloop -d cloop'):fork() - --__('sleep 1'):Do() - --__('jack_connect cloop:capture_1 system:playback_1'):Do() - --__('jack_connect cloop:capture_2 system:playback_2'):Do() + __'alsa_in -j cloop -d cloop':fork() + --__[[sleep 1 + -- jack_connect cloop:capture_1 system:playback_1o() + -- jack_connect cloop:capture_2 system:playback_2]]:Do() print("HW playback: ploop\tDEVICE: ploop") - __('alsa_out -j ploop -d ploop'):fork() - --__('sleep 1'):Do() - --__('jack_connect system:capture_1 ploop:playback_1'):Do() - --__('jack_connect system:capture_2 ploop:playback_2'):Do() + __'alsa_out -j ploop -d ploop':fork() + --__[[sleep 1 + -- jack_connect system:capture_1 ploop:playback_1 + -- jack_connect system:capture_2 ploop:playback_2]]:Do() print("") @@ -424,7 +422,7 @@ elseif 'JACK' == args[1] then for j,c in ipairs(C['playbackDevs']) do print("HW playback: " .. C['name'] .. "\tDEVICE: " .. C['playbackDevs'][j]) __(AOUT .. ' -j ' .. C['name'] .. "_" .. C['playbackDevs'][j] .. '-in -d ' .. C['name'] .. C['playbackDevs'][j]):fork() - -- __('sleep 1'):Do() + -- __'sleep 1':Do() -- __('jack_connect cloop:capture_1 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_1'):Do() -- __('jack_connect cloop:capture_2 ' .. C['name'] .. '_' .. C['playbackDevs'][j] .. '-in' .. ':playback_2'):Do() end @@ -435,9 +433,9 @@ elseif 'JACK' == args[1] then end print("") - if _.exists('aseqjoy') then + if _.runnable('aseqjoy') then print("Scanning for joysticks.") - local sticks = __('ls -1 /dev/input/js[0-9]*'):noErr():Do() + local sticks = __'ls -1 /dev/input/js[0-9]*':noErr():Do() for i,l in ipairs(sticks.lines) do print("aseqjoy " .. l) -- Buttons switch to that numbered MIDI channel, defaults to 1. @@ -448,14 +446,14 @@ elseif 'JACK' == args[1] then print("") end - if _.exists('jack-plumbing') then + if _.runnable('jack-plumbing') then print('Stop our jack-plumbing, eventually.') - __('sleep 4'):Do() + __'sleep 4':Do() _.killEmAll{"jack-plumbing"} end - if _.exists('~/.aataaj_JACK.lua') then + if _.runnable('~/.aataaj_JACK.lua') then print('Running users aataaj_JACK.lua') - __('~/.aataaj_JACK.lua'):Do() + __'~/.aataaj_JACK.lua':Do() end end -- cgit v1.1