-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenbox.lua
86 lines (63 loc) · 2.21 KB
/
openbox.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
76
77
78
79
80
81
82
83
84
--[[
-- OPENBOX ***************************************
]]--
function Openbox_ItemWrite(S, item)
local invoke
if item.type=="group"
then
Openbox_SubmenuWrite(S, item.name, item)
elseif item.invoke ~= nil
then
icon=AppIconFind(item, settings.icon_path)
if icon==nil then icon="" end
-- 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("<item label=\"" .. item.name.. "\" icon=\""..icon.."\"><action name=\"Execute\"><command>/bin/sh -c \"" .. invoke.."\"</command></action></item>\n")
else
S:writeln("<item label=\"" .. item.name.. "\" icon=\""..icon.."\"><action name=\"Execute\"><command>" .. invoke.."</command></action></item>\n")
end
end
end
function Openbox_ItemsWrite(S, items)
local name, item
for name,item in pairs(items)
do
Openbox_ItemWrite(S, item)
end
end
function Openbox_SubmenuWrite(S, title, group)
local name, icon
name,icon=GroupInfoFind(group)
if icon == nil then icon="" end
S:writeln("<menu id=\""..title.. "\" label=\""..title.."\" icon=\"" .. icon.. "\">\n")
Openbox_ItemsWrite(S, group)
S:writeln("</menu>\n")
end
function Openbox_MenuWrite(menu, Path)
local i, item, S
S=OpenOutputFile(Path)
if S ~= nil
then
S:writeln("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
S:writeln("<openbox_menu xmlns=\"http://openbox.org/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://openbox.org/ file:///usr/share/openbox/menu.xsd\">\n")
S:writeln("<menu id=\"root-menu\" label=\"Openbox\">\n")
if #faves_config > 0
then
Openbox_ItemsWrite(S, faves_config)
S:writeln("<separator />\n")
end
Openbox_ItemsWrite(S, menu)
S:writeln("<separator />\n")
S:writeln("<item label=\"Reconfigure\"><action name=\"Reconfigure\"/></item>\n")
S:writeln("<item label=\"Restart\"><action name=\"Restart\"/></item>\n")
S:writeln("<item label=\"Exit\"><action name=\"Exit\"/></item>\n")
S:writeln("</menu>\n")
S:writeln("</openbox_menu>\n")
S:close()
os.execute("openbox --reconfigure")
end
end