summaryrefslogtreecommitdiff
path: root/apps/plugins/lua_scripts/dump_rbsettings.lua
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-09-06 19:24:26 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-09-07 03:10:59 +0200
commit267d04d2bd2a7681c8bbcfbb655612101440b765 (patch)
treea518b4c10244cc77a5eee636132031c5a542c00a /apps/plugins/lua_scripts/dump_rbsettings.lua
parenta3cbd86a5193e5227344db360f45f114fda10aab (diff)
downloadrockbox-267d04d2bd2a7681c8bbcfbb655612101440b765.tar.gz
rockbox-267d04d2bd2a7681c8bbcfbb655612101440b765.zip
Lua add metadata and settings reading helper module
Adds example scripts for reading track metadata + dumping albumart and rockbox settings settings are now stored as a table of strings rather than a table of tables as it saves ~15 kb of ram without adding much complexity Change-Id: I611c312b2a60ab96e595e4710b17aedbd6c0689b
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)