-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscan_directories.lua
More file actions
57 lines (44 loc) · 1.21 KB
/
scan_directories.lua
File metadata and controls
57 lines (44 loc) · 1.21 KB
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
-- functions related to scanning directories in the users PATH for applications that have
-- been specified in the menubuilder.conf file, or for any .desktop files
-- scan a directory for applications
function ScanDir(dir)
local config, files, curr, name
files=filesys.GLOB(dir.."/*")
curr=files:next()
while curr ~= nil
do
name=filesys.basename(curr)
--directories have no name, so ignore those
if strutil.strlen(name) > 0
then
config=AppConfigFind(name)
if config ~= nil and config.group ~=nil
then
-- is it a dialog app, like XDialog, Zenity or Qarma? If so then add it to the dialog_apps table
if config.group == "DialogApp"
then
--do nothing for now, one day we hope to automagically find qarma, zenity, xdialog etc
else
--it's a normal app, so add it to it's menu group
MenuAddItem(config.group, config)
if config.implies ~= nil then ProcessImpliedApps(config.implies) end
end
end
end
curr=files:next()
end
end
function ScanDirectoriesInPath()
local toks, dir, prefix, PATH
PATH=process.getenv("PATH")
toks=strutil.TOKENIZER(PATH,":")
dir=toks:next()
while dir ~= nil
do
ScanDir(dir)
prefix=string.gsub(dir, "/bin$", "")
LoadDesktopFiles(prefix)
IconPathAdd(prefix)
dir=toks:next()
end
end