Private naughty.getIcon() -> public awful.util.geticonpath()
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
bb3fc70fb3
commit
3636b884d3
|
@ -174,6 +174,24 @@ function getdir(d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Search for an icon and return the full path.
|
||||||
|
-- It searches for the icon path under the directories given w/the right ext
|
||||||
|
-- @param iconname The name of the icon to search for.
|
||||||
|
-- @param exts Table of image extensions allowed, otherwise { 'png', gif' }
|
||||||
|
-- @param dirs Table of dirs to search, otherwise { '/usr/share/pixmaps/' }
|
||||||
|
function geticonpath(iconname, exts, dirs)
|
||||||
|
exts = exts or { 'png', 'gif' }
|
||||||
|
dirs = dirs or { '/usr/share/pixmaps/' }
|
||||||
|
for _, d in pairs(dirs) do
|
||||||
|
for _, e in pairs(exts) do
|
||||||
|
local icon = d .. iconname .. '.' .. e
|
||||||
|
if file_readable(icon) then
|
||||||
|
return icon
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if file exists and is readable.
|
--- Check if file exists and is readable.
|
||||||
-- @param filename The file path
|
-- @param filename The file path
|
||||||
-- @return True if file exists and readable.
|
-- @return True if file exists and readable.
|
||||||
|
|
|
@ -243,20 +243,6 @@ local function getById(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Search for an icon in specified directories with a specified format
|
|
||||||
-- @param icon Name of the icon
|
|
||||||
-- @return full path of the icon, or nil of no icon was found
|
|
||||||
local function getIcon(name)
|
|
||||||
for d, dir in pairs(config.icon_dirs) do
|
|
||||||
for f, format in pairs(config.icon_formats) do
|
|
||||||
local icon = dir .. name .. "." .. format
|
|
||||||
if util.file_readable(icon) then
|
|
||||||
return icon
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create notification. args is a dictionary of (optional) arguments.
|
--- Create notification. args is a dictionary of (optional) arguments.
|
||||||
-- @param text Text of the notification. Default: ''
|
-- @param text Text of the notification. Default: ''
|
||||||
-- @param title Title of the notification. Default: nil
|
-- @param title Title of the notification. Default: nil
|
||||||
|
@ -397,7 +383,7 @@ function notify(args)
|
||||||
if icon then
|
if icon then
|
||||||
-- try to guess icon if the provided one is non-existent/readable
|
-- try to guess icon if the provided one is non-existent/readable
|
||||||
if type(icon) == "string" and not util.file_readable(icon) then
|
if type(icon) == "string" and not util.file_readable(icon) then
|
||||||
icon = getIcon(icon)
|
icon = util.geticonpath(icon, config.icon_formats, config.icon_dirs)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if we have an icon, use it
|
-- if we have an icon, use it
|
||||||
|
|
Loading…
Reference in New Issue