lcpz / awesome-freedesktop

Freedesktop.org menu and desktop icons support for Awesome WM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Desktop.lua icon defaults do not work

rjhwelsh opened this issue · comments

Hi,

I noticed there is an issue with the default desktop icons (using the adwaita theme) on awesome v4.3.

I traced it back to menubar.utils.lua

Since the introduction of Menubar as core library for providing Freedesktop.org menu functionalities in Awesome, we can now avoid all the dirty work by just exploiting menubar.utils functions.

local function get_icon_lookup_path()

...

 local app_in_theme_paths = {}
    for _, icon_theme_directory in ipairs(icon_theme_paths) do
        for _, size in ipairs(all_icon_sizes) do
            table.insert(app_in_theme_paths,
                         glib.build_filenamev({ icon_theme_directory,
                                                size, 'apps' }))
            table.insert(app_in_theme_paths,
                         glib.build_filenamev({ icon_theme_directory,
                                                size, 'categories' }))
        end
    end

...

You might not notice right away, but it only adds icons in the "apps" and "categories" directories to the search path.
All the others are ignored.

As a workaround I re-wrote utils.lua section to :

local app_in_theme_paths = {}
    for _, icon_theme_directory in ipairs(icon_theme_paths) do
        for _, size in ipairs(all_icon_sizes) do
	    for _, icon_type in ipairs({'apps', 'categories', 'mimetypes', 'places', 'legacy'}) do    
            table.insert(app_in_theme_paths,
                         glib.build_filenamev({ icon_theme_directory,
                                                size, icon_type}))
             end
        end
    end

So now it takes mimetypes, places and legacy as places to search also.

I'm not convinced it is an issue with menubar, because I believe apps and categories are the relevant sections for that app.
So I just wanted to document it here, in-case others have issues with the icons and they don't have to figure it out.

I might pose a generic icon search interface as a feature request to the AwesomeWM croud later.

So, there's some dirty work for you. ;)

As a workaround I re-wrote utils.lua section to :

Create a new pull request, fixing menubar won't be done anytime soon, thus we can keep this workaround for the time being.

Is there any way in Lua to change an internal function of another module?

I think you can do something quick and inelegant like this:

local utils = require("menubar.utils")
function utils.get_icon_lookup_path()
    -- hic sunt dracones
end

But I trust you can come up with an ingenious solution (aka feel free to do the dirty work for me 🤪).