Many themes have prerendered icons of different sizes stored in
subdirectories named as '<size>x<size>'. By looking in these directories
when a specific icon size is specified, we can support themes in a
rather straightforward way.
---
 lib/awful/util.lua.in |   14 ++++++++++++--
 lib/naughty.lua.in    |    2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/awful/util.lua.in b/lib/awful/util.lua.in
index 2c6622c..8c326fe 100644
--- a/lib/awful/util.lua.in
+++ b/lib/awful/util.lua.in
@@ -180,12 +180,22 @@ end
 -- @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)
+-- @param size Optional size. If this is specified, subdirectories 
<size>x<size>
+--             of the dirs are searched first
+function geticonpath(iconname, exts, dirs, size)
     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
+            local icon
+            if size then
+                icon = string.format("%s%ux%u/%s.%s",
+                       d, size, size, iconname, e)
+                if file_readable(icon) then
+                    return icon
+                end
+            end
+            icon = d .. iconname .. '.' .. e
             if file_readable(icon) then
                 return icon
             end 
diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in
index be19811..28f4803 100644
--- a/lib/naughty.lua.in
+++ b/lib/naughty.lua.in
@@ -405,7 +405,7 @@ function notify(args)
     if icon then
         -- try to guess icon if the provided one is non-existent/readable
         if type(icon) == "string" and not util.file_readable(icon) then
-            icon = util.geticonpath(icon, config.icon_formats, 
config.icon_dirs)
+            icon = util.geticonpath(icon, config.icon_formats, 
config.icon_dirs, icon_size)
         end
 
         -- if we have an icon, use it
-- 
1.7.10.rc3.204.g95589


-- 
To unsubscribe, send mail to [email protected].

Reply via email to