widget: search for an alternative icon if none available

If no icon is available for the tasklist, search for an alternative
one. Also set the application icon to avoid to search again
later. Maybe this would be better to search for an icon when managing
the new window?
This commit is contained in:
Vincent Bernat 2012-07-09 15:53:11 +02:00
parent c8df51894e
commit f6e37460a5

View file

@ -175,7 +175,26 @@ for s = 1, screen.count() do
if screen.count() > 1 then if screen.count() > 1 then
tasklist[s] = awful.widget.tasklist( tasklist[s] = awful.widget.tasklist(
function(c) function(c)
return awful.widget.tasklist.label.currenttags(c, s) local title, color, _, icon = awful.widget.tasklist.label.currenttags(c, s)
-- Try to search for an alternative icon if none is available
for _, name in pairs({c.class, c.instance}) do
if not icon and title and name then
for _, n in pairs({name, name:lower()}) do
icon = awful.util.geticonpath(name,
nil,
{"/usr/share/fvwm-crystal/fvwm/icons/Default/16x16/apps/",
"/usr/share/fvwm-crystal/fvwm/icons/Default/22x22/apps/",
"/usr/share/icons/hicolor/16x16/apps/"})
if icon then
-- This is our new icon. And we set it for the client to not search again
icon = image(icon)
c.icon = icon
end
end
end
end
-- Use our icon and don't set the status image.
return title, color, nil, icon
end, tasklist.buttons) end, tasklist.buttons)
else else
tasklist[s] = "" tasklist[s] = ""