-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtwm.lua
64 lines (45 loc) · 1.1 KB
/
twm.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function TWM_ItemsWrite(S, group)
local conf, name, item
for name,item in pairs(group)
do
if item.type=="group"
then
S:writeln(" \""..item.name.. "\" f.menu \"" .. string.gsub(item.name, " ", "_").. "\"\n")
elseif item.invoke ~= nil
then
S:writeln(" \"".. item.name .. "\" f.exec \"" .. item.invoke .. "&\"\n")
end
end
end
function TWM_SubmenuWrite(S, group)
local name, item
-- First go through and write out all the submenus
for name,item in pairs(group)
do
if item.type=="group" then TWM_SubmenuWrite(S, item) end
end
S:writeln("Menu \"" .. string.gsub(group.name, " ", "_") .. "\"\n{\n")
if group.name=="RootMenu" and #faves_config > 0
then
S:writeln("\"Root Menu\" f.title\n")
TWM_ItemsWrite(S, faves_config)
S:writeln("\"no-label\" f.separator\n")
end
TWM_ItemsWrite(S, group)
if group.name == "RootMenu"
then
S:writeln("\"no-label\" f.separator\n")
S:writeln("\"Restart\" f.restart\n")
S:writeln("\"Exit\" f.quit\n")
end
S:writeln("}\n\n")
end
function TWM_MenuWrite(menu, Path)
local i, item, S
S=OpenOutputFile(Path)
if S ~= nil
then
TWM_SubmenuWrite(S, menu)
S:close()
end
end