-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblackbox.lua
77 lines (56 loc) · 1.48 KB
/
blackbox.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
63
64
65
66
67
68
69
70
71
72
73
74
75
--[[
-- BLACKBOX/FLUXBOX/HACKEDBOX ***************************************
]]--
function Blackbox_ItemWrite(S, item)
local invoke
if item.type=="group"
then
Blackbox_SubmenuWrite(S, item.name, item)
elseif item.invoke ~= nil
then
-- blackbox dequotes these when running them
invoke=string.gsub(item.invoke, "\\", "\\\\")
--if there's arguments then it's likely that some form of shell replacement (e.g. '*') or shell variables are
--being used, so we run this command under a shell
if string.find(invoke, ' ') ~= nil
then
S:writeln("[exec] (" .. item.name.. ") {/bin/sh -c \"" .. invoke.."\"}\n")
else
S:writeln("[exec] (" .. item.name.. ") {" .. invoke.."}\n")
end
end
end
function Blackbox_ItemsWrite(S, items)
local name, item
for name,item in pairs(items)
do
Blackbox_ItemWrite(S, item)
end
end
function Blackbox_SubmenuWrite(S, title, group)
S:writeln("[submenu] ("..title..")\n")
Blackbox_ItemsWrite(S, group)
S:writeln("[end]\n")
end
function Blackbox_MenuWrite(menu, Path)
local i, item, S
S=OpenOutputFile(Path)
if S ~= nil
then
S:writeln("[begin] (Root Menu)\n")
if #faves_config > 0
then
Blackbox_ItemsWrite(S, faves_config)
S:writeln("[nop]\n")
end
Blackbox_ItemsWrite(S, menu)
S:writeln("[nop]\n")
S:writeln("[workspaces] (workspace menu)\n")
S:writeln("[config] (blackbox config)\n")
S:writeln("[reconfig] (Reconfigure)\n")
S:writeln("[restart] (Restart)\n")
S:writeln("[exit] (Exit)\n")
S:writeln("[end]\n")
S:close()
end
end