From c93e075ef2c477b902b2d0cb55ca7c342655f2c1 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Sat, 26 Oct 2024 21:36:27 +1000 Subject: Move aataaj.lua configuration options to a conf file. --- .aataaj.conf.lua | 12 ++++++++++++ aataaj.lua | 44 ++++++++++++++++---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 .aataaj.conf.lua diff --git a/.aataaj.conf.lua b/.aataaj.conf.lua new file mode 100644 index 0000000..642d24c --- /dev/null +++ b/.aataaj.conf.lua @@ -0,0 +1,12 @@ +-- This works coz LuaJIT automatically loads the jit module. +if type(jit) == 'table' then + io.write(arg[0] .. ' is being run by ' .. jit.version .. ' under ' .. jit.os .. ' on a ' .. jit.arch .. '\n') +else + io.write(arg[0] .. ' is being run by Lua version ' .. _VERSION .. '\n') +end + +return { + ['aliases'] = { + {name='Screen', dev='HDMI9'}, + }; +} diff --git a/aataaj.lua b/aataaj.lua index 6f840f3..eaa0fef 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -86,24 +86,12 @@ Version = '0.0 crap' local options = { - start = - { - help = 'Command to start the scanning process, for Sys V init.', - }, + start = {help = 'Command to start the scanning process, for Sys V init.', }, restart = {start}, ['force-reload'] = {start}, - status = - { - help = 'Command to check the status of the scanning process, for Sys V init.', - }, - stop = - { - help = 'Command to stop the scanning process, for Sys V init.', - }, - JACK = - { - help = 'Command to start the JACK stuff, for users.', - }, + status = {help = 'Command to check the status of the scanning process, for Sys V init.', }, + stop = {help = 'Command to stop the scanning process, for Sys V init.', }, + JACK = {help = 'Command to start the JACK stuff, for users.', }, STOP = { help = 'Command to stop the JACK stuff, for users.', @@ -132,24 +120,24 @@ local options = os.exit(0) end }, + asoundrcPath = {help = 'Path to our config files and stuff.', value = '/var/lib/aataaj', }, + asoundrc = {help = 'Name of asoundrc file.', value = 'asoundrc', }, + aliases = {help = 'Aliases for audio devices.', value = {}, }, } -_.parse(arg, options) +_.parse(arg, options, 'aataaj') -- CHANGE these to suit. -local asoundrcPath = '/var/lib/aataaj' -local asoundrc = 'asoundrc' local GUI = 'qjackctl' if _.runnable('catia') then GUI = 'catia' end -local alias = { --- {name='Screen', dev='HDMI9'}, - } local speaker = 'espeak' if _.runnable('espeak-ng') then speaker = 'espeak-ng' end + + local Cards = {} print('Scanning for audio devices.') @@ -212,9 +200,9 @@ io.flush() if 'start' == arg[1] then - __('mkdir -p ' .. asoundrcPath):Do() - local a, e = io.open(asoundrcPath .. '/jack-plumbing', "w") - if nil == a then print("Could not open " .. asoundrcPath .. '/jack-plumbing') else + __('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') else a:write([[ (connect "system:capture_1" "ploop:playback_1") (connect "system:capture_2" "ploop:playback_2") @@ -228,8 +216,8 @@ if 'start' == arg[1] then ]]) a:close() end - local a, e = io.open(asoundrcPath .. '/' .. asoundrc, "w") - if nil == a then print("Could not open " .. asoundrcPath .. '/' .. asoundrc) else + local a, e = io.open(options.asoundrcPath.value .. '/' .. options.asoundrc.value, "w") + if nil == a then print("Could not open " .. options.asoundrcPath.value .. '/' .. options.asoundrc.value) else for i,C in pairs(Cards) do for j,c in pairs(C['devs']) do a:write("pcm." .. C['name'] .. j .. " {\n") @@ -420,7 +408,7 @@ elseif 'JACK' == arg[1] then if _.runnable'zita-j2a' then AOUT = 'zita-j2a' end print("Basic ALSA sound devices converted to JACK.") - for i,C in pairs(alias) do + for i,C in pairs(options.aliases.value) do print('HW playback: ' .. C['name'] .. '\tDEVICE: ' .. C['dev']) __(AOUT .. ' -j ' .. C['name'] .. ' -d ' .. C['dev']):fork() end -- cgit v1.1