menubar: improve path icon behavior
This adds $XDG_DATA_DIRS and HOME/.icons for icon lookups.
This commit is contained in:
parent
3a160c9363
commit
c315687dad
|
@ -11,6 +11,7 @@ local ipairs = ipairs
|
||||||
local string = string
|
local string = string
|
||||||
local awful_util = require("awful.util")
|
local awful_util = require("awful.util")
|
||||||
local theme = require("beautiful")
|
local theme = require("beautiful")
|
||||||
|
local glib = require("lgi").GLib
|
||||||
|
|
||||||
-- Utility module for menubar
|
-- Utility module for menubar
|
||||||
-- menubar.utils
|
-- menubar.utils
|
||||||
|
@ -80,12 +81,15 @@ function utils.lookup_icon(icon_file)
|
||||||
local icon_path = {}
|
local icon_path = {}
|
||||||
local icon_theme_paths = {}
|
local icon_theme_paths = {}
|
||||||
local icon_theme = theme.icon_theme
|
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
|
if icon_theme then
|
||||||
table.insert(icon_theme_paths, '/usr/share/icons/' .. icon_theme .. '/')
|
table.insert(icon_theme_paths, dir..'/icons/' .. icon_theme .. '/')
|
||||||
-- TODO also look in parent icon themes, as in freedesktop.org specification
|
end
|
||||||
|
table.insert(icon_theme_paths, dir..'/icons/hicolor/') -- fallback theme
|
||||||
end
|
end
|
||||||
table.insert(icon_theme_paths, '/usr/share/icons/hicolor/') -- fallback theme
|
|
||||||
|
|
||||||
for i, icon_theme_directory in ipairs(icon_theme_paths) do
|
for i, icon_theme_directory in ipairs(icon_theme_paths) do
|
||||||
for j, size in ipairs(all_icon_sizes) do
|
for j, size in ipairs(all_icon_sizes) do
|
||||||
table.insert(icon_path, icon_theme_directory .. size .. '/apps/')
|
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/')
|
table.insert(icon_path, icon_theme_directory .. size .. '/status/')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for k,dir in ipairs(paths)do
|
||||||
-- lowest priority fallbacks
|
-- lowest priority fallbacks
|
||||||
table.insert(icon_path, '/usr/share/pixmaps/')
|
table.insert(icon_path, dir..'/pixmaps/')
|
||||||
table.insert(icon_path, '/usr/share/icons/')
|
table.insert(icon_path, dir..'/icons/')
|
||||||
|
end
|
||||||
for i, directory in ipairs(icon_path) do
|
for i, directory in ipairs(icon_path) do
|
||||||
if is_format_supported(icon_file) and awful_util.file_readable(directory .. icon_file) then
|
if is_format_supported(icon_file) and awful_util.file_readable(directory .. icon_file) then
|
||||||
return directory .. icon_file
|
return directory .. icon_file
|
||||||
|
|
Loading…
Reference in New Issue