From f6e37460a5a70c425899b87901f1da379b458080 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 9 Jul 2012 15:53:11 +0200 Subject: [PATCH] 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? --- rc/widgets.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rc/widgets.lua b/rc/widgets.lua index 790aa89..9611633 100644 --- a/rc/widgets.lua +++ b/rc/widgets.lua @@ -175,7 +175,26 @@ for s = 1, screen.count() do if screen.count() > 1 then tasklist[s] = awful.widget.tasklist( 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) else tasklist[s] = ""