-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathicons.lua
More file actions
155 lines (111 loc) · 2.96 KB
/
icons.lua
File metadata and controls
155 lines (111 loc) · 2.96 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
--[[
-- ICON FIND FUNCS ***************************************************
]]--
function IconFind(srcname, path)
local str, i, extn, name
if srcname==nil then return(nil) end
if settings.find_icons == false then return end
if strutil.strlen(srcname) < 1 then return(nil) end
name=string.lower(srcname)
if icon_cache[name] ~=nil
then
return icon_cache[name]
end
return nil
end
function IconFindFromList(icon_list)
local toks, name, icon
if settings.find_icons == false then return end
toks=strutil.TOKENIZER(icon_list, ",")
name=toks:next()
while name ~= nil
do
icon=IconFind(name, settings.icon_path)
if icon ~=nil then return icon end
name=toks:next()
end
return nil
end
function IconsLoad(path)
local toks, dir
if settings.find_icons == false then return end
toks=strutil.TOKENIZER(path, ":")
dir=toks:next()
while dir ~= nil
do
files=filesys.GLOB(dir.."*.[jJpP]*[gG]")
file=files:next()
while file ~= nil
do
extn=string.lower(filesys.extn(file))
if extn==".jpg" or extn==".jpeg" or extn==".png"
then
name=filesys.basename(file)
name=string.sub(name, 1, string.len(name)-string.len(extn))
name=string.lower(name)
if icon_cache[name] == nil then icon_cache[name]=file end
end
file=files:next()
end
dir=toks:next()
end
end
function AppIconFind(app, path)
local icons, icon, conf, item
if settings.find_icons == false then return nil end
icons=strutil.TOKENIZER(app.icons)
item=icons:next()
while item ~= nil
do
-- are any of the 'names' given in 'icons' actually paths?
-- this check allows specifiying a full path to an icon within a desktop file
if strutil.strlen(item) > 0 and filesys.exists(item) == true then return item end
icon=IconFind(item, path)
if icon ~= nil then return icon end
item=icons:next()
end
icon=IconFind(app.exec, path)
if icon ~= nil then return icon end
icon=IconFind(app.name, path)
if icon ~= nil then return icon end
icon=IconFindFromList(app.icons)
if icon ~= nil then return icon end
icon=IconFindFromList(app.groups)
if icon ~= nil then return icon end
conf=FindGroup(app.group)
if conf ~= nil and conf.icon ~= nil then return conf.icon end
if app.parent ~= nil
then
conf=FindGroup(app.parent.name)
if conf ~= nil and conf.icon ~= nil then return conf.icon end
end
return nil
end
function IconPathAddDir(prefix, dir)
local str
str=prefix.."/"..dir
if filesys.exists(str) == true then settings.icon_path = settings.icon_path .. str .. ":" end
end
function IconPathAdd(prefix)
local fslist, dir
local subdirs={"128x128","64x64","48x48","32x32", "16x16"}
IconPathAddDir(prefix, "/share/icons/")
IconPathAddDir(prefix, "/share/pixmaps/")
fslist=filesys.GLOB(prefix.."/share/icons/*")
dir=fslist:next()
while dir ~= nil
do
if fslist:info().type == "directory"
then
IconPathAddDir(dir, "")
for i,sub in ipairs(subdirs)
do
IconPathAddDir(dir, sub .. "/")
IconPathAddDir(dir, sub .."/apps/")
IconPathAddDir(dir, sub .."/places/")
IconPathAddDir(dir, sub .."/devices/")
end
end
dir=fslist:next()
end
end