Skip to content

script_manager - delay script start until all libraries are scanned #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion tools/script_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ sm.log_level = DEFAULT_LOG_LEVEL
]]

sm.scripts = {}
sm.start_queue = {}
sm.page_status = {}
sm.page_status.num_buttons = DEFAULT_BUTTONS_PER_PAGE
sm.page_status.buttons_created = 0
Expand Down Expand Up @@ -595,6 +596,17 @@ local function deactivate(script)
restore_log_level(old_log_level)
end

local function start_scripts()
for _, script in ipairs(sm.start_queue) do
activate(script)
end
sm.start_queue = {}
end

local function queue_script_to_start(script)
table.insert(sm.start_queue, script)
end

local function add_script_name(name, path, folder)
local old_log_level = set_log_level(sm.log_level)

Expand All @@ -614,7 +626,7 @@ local function add_script_name(name, path, folder)
table.insert(sm.scripts[folder], script)

if pref_read(script.script_name, "bool") then
activate(script)
queue_script_to_start(script)
else
pref_write(script.script_name, "bool", false)
end
Expand Down Expand Up @@ -821,6 +833,7 @@ local function scan_repositories()
end
end

start_scripts()
update_script_update_choices()

restore_log_level(old_log_level)
Expand Down