From b45c7089c638202ab20dfbacf06b5a6f408509da Mon Sep 17 00:00:00 2001 From: Nikolaus Gullotta Date: Wed, 1 Aug 2018 14:42:02 -0500 Subject: [PATCH] implement fetch_valid_settings_file() to avoid the user having to see stub files --- scripts/mixer_settings_recall.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/mixer_settings_recall.lua b/scripts/mixer_settings_recall.lua index f8e22276dd..af07256b4c 100644 --- a/scripts/mixer_settings_recall.lua +++ b/scripts/mixer_settings_recall.lua @@ -47,6 +47,19 @@ function factory () return function () return exists(path.."/") end + function fetch_valid_settings_file(directory, fallback) + local i, t, popen = 0, {}, io.popen + local pfile = popen('ls "'..directory..'"') + for filename in pfile:lines() do + i = i + 1 + if string.find(filename, ".lua") then + return filename + end + end + pfile:close() + return fallback + end + function get_processor_by_name(track, name) local i = 0 local proc = track:nth_processor(i) @@ -377,7 +390,7 @@ function factory () return function () else if gvld['recall-dir'] == 1 then local global_ok = isdir(global_path) - local global_default_path = ARDOUR.LuaAPI.build_filename(global_path, string.format("FactoryDefault-%s.lua", whoami())) + local global_default_path = ARDOUR.LuaAPI.build_filename(global_path, fetch_valid_settings_file(global_path, string.format("FactoryDefault-%s.lua", whoami()))) print(global_default_path) if global_ok then recall_options[2]['path'] = global_default_path @@ -398,10 +411,10 @@ function factory () return function () if gvld['recall-dir'] == 2 then local local_ok = isdir(local_path) - local local_default_path = ARDOUR.LuaAPI.build_filename(local_path, 'stub') + local local_default_path = ARDOUR.LuaAPI.build_filename(local_path, fetch_valid_settings_file(local_path)) print(local_default_path) if local_ok then - recall_options[2]['path'] = local_path + recall_options[2]['path'] = local_default_path local rv = LuaDialog.Dialog("Recall Mixer Settings:", recall_options):run() if not(rv) then return end local dry_return = LuaDialog.Dialog("Mixer Store:", dry_run(false, rv['file'])):run()