Add Profile dumper and Profile save/restore widgets

This commit is contained in:
Evgeny
2024-09-21 10:27:33 +03:00
parent 1580867d31
commit d6e4e53da5
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
-- name = "Profile Switcher"
-- version = "1.0"
-- description = "Tap: restore profile / Long-press: save to profile"
-- type = "widget"
-- author = "Marcus Johansson"
local profs
local profile
function on_load()
profs = profiles:list()
ui:show_buttons(profs)
end
function on_click(idx)
profile = profs[idx]
profiles:restore(profile)
ui:show_toast(profile..": Restored")
end
function on_long_click(idx)
profile = profs[idx]
title = 'Save to "'..profile..'" ?'
text = 'Do you want to save the current screen state to the "'..profile..'" profile ?'
ui:show_dialog(title, text, "Yes", "Cancel")
end
function on_dialog_action(value)
if value == 1 then
profiles:dump(profile)
ui:show_toast(profile..": Saved")
elseif value == 2 then
ui:show_toast("Canceled")
end
end