summaryrefslogtreecommitdiff
path: root/apps/plugins/lua_scripts/dump_rbsettings.lua
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lua_scripts/dump_rbsettings.lua')
-rw-r--r--apps/plugins/lua_scripts/dump_rbsettings.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/plugins/lua_scripts/dump_rbsettings.lua b/apps/plugins/lua_scripts/dump_rbsettings.lua
new file mode 100644
index 0000000000..2811d27487
--- /dev/null
+++ b/apps/plugins/lua_scripts/dump_rbsettings.lua
@@ -0,0 +1,49 @@
1require("rbsettings")
2require("settings")
3rb.metadata = nil -- remove track metadata settings
4-------------------------------------------------------------------------------
5
6local function print_setting_table(t_tbl, s_sep)
7 s_sep = s_sep or ""
8 local str = ""
9 local function pfunct(t, sep, s, n) -- recursive print function
10 local vtype
11 for k, v in pairs(t) do
12 vtype = type(v)
13 if vtype == "table" then
14 local f = string.format("%s[%s]", n, k)
15 s = pfunct(v, sep, s, f)
16 elseif vtype == "boolean" then
17 v = v and "true" or "false"
18 s = string.format("%s%s[%s] = %s%s", s, n, k, v, sep)
19 elseif v then
20 s = string.format("%s%s[%s] = %s%s", s, n, k, v, sep)
21 end
22 end
23 return s
24 end
25 return pfunct(t_tbl, s_sep, str, "")
26end
27
28local filename = "/settings.txt"
29local file = io.open(filename, "w+") -- overwrite
30local t_settings
31
32if not file then
33 rb.splash(rb.HZ, "Error writing " .. filename)
34 return
35end
36
37t_settings = rb.settings.dump('global_settings', "system")
38file:write("global_settings:\n")
39file:write(print_setting_table(t_settings, "\n"))
40file:write("\n\n")
41
42t_settings = rb.settings.dump('global_status', "system")
43file:write("global_status:\n")
44file:write(print_setting_table(t_settings, "\n"))
45file:write("\n\n")
46
47file:close()
48
49rb.splash(100, "rb settings dumped: " .. filename)