menubar: improve path icon behavior

This adds $XDG_DATA_DIRS and HOME/.icons for icon lookups.
This commit is contained in:
salorium 2015-02-05 19:42:49 +01:00 committed by Daniel Hahler
parent 3a160c9363
commit c315687dad
1 changed files with 14 additions and 9 deletions

View File

@ -11,6 +11,7 @@ local ipairs = ipairs
local string = string
local awful_util = require("awful.util")
local theme = require("beautiful")
local glib = require("lgi").GLib
-- Utility module for menubar
-- menubar.utils
@ -80,12 +81,15 @@ function utils.lookup_icon(icon_file)
local icon_path = {}
local icon_theme_paths = {}
local icon_theme = theme.icon_theme
local paths = glib.get_system_data_dirs()
table.insert(paths,1,glib.get_user_data_dir())
table.insert(paths,1,glib.get_home_dir() .. '/.icons')
for k,dir in ipairs(paths)do
if icon_theme then
table.insert(icon_theme_paths, '/usr/share/icons/' .. icon_theme .. '/')
-- TODO also look in parent icon themes, as in freedesktop.org specification
table.insert(icon_theme_paths, dir..'/icons/' .. icon_theme .. '/')
end
table.insert(icon_theme_paths, dir..'/icons/hicolor/') -- fallback theme
end
table.insert(icon_theme_paths, '/usr/share/icons/hicolor/') -- fallback theme
for i, icon_theme_directory in ipairs(icon_theme_paths) do
for j, size in ipairs(all_icon_sizes) do
table.insert(icon_path, icon_theme_directory .. size .. '/apps/')
@ -96,10 +100,11 @@ function utils.lookup_icon(icon_file)
table.insert(icon_path, icon_theme_directory .. size .. '/status/')
end
end
for k,dir in ipairs(paths)do
-- lowest priority fallbacks
table.insert(icon_path, '/usr/share/pixmaps/')
table.insert(icon_path, '/usr/share/icons/')
table.insert(icon_path, dir..'/pixmaps/')
table.insert(icon_path, dir..'/icons/')
end
for i, directory in ipairs(icon_path) do
if is_format_supported(icon_file) and awful_util.file_readable(directory .. icon_file) then
return directory .. icon_file