awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.39k stars 597 forks source link

Suggestion: Use index.theme to process icons instead of using hard-coded paths #3449

Open ArtyIF opened 3 years ago

ArtyIF commented 3 years ago

I'm using the latest Awesome git version (AUR), and I noticed a bit of a problem - when using icon themes that deviate from the SIZExSIZE/CATEGORY/ICONNAME.EXT format (for example, 32x32/apps/accessories-calculator.png), the icons there can't be found. There are themes like Breeze, Oxygen and Adwaita++ that use the CATEGORY/SIZE/ICONNAME.EXT format for paths (i.e. apps/32/accessories-calculator.png). While this format can be added into the current menubar.utils.lookup_icon_uncached function, this still makes it inflexible since there's probably other formats.

For icon themes, most desktop environments use a file in theme folders called index.theme, which is an INI format file that tells where various categories and sizes are located. Examples from Breeze theme (ignore the comments, they're KDE-specific I think):

#48x48 - Fixed size - For dialog icons >!!!ONLY!!!< - DO_NOT_USE_ANYWHERE_ELSE - Color
[status/48]
Size=48
Context=Status
Type=Fixed

#64x64 - Fixed size - For dialog icons >!!!ONLY!!!< - DO_NOT_USE_ANYWHERE_ELSE - Color
[status/64]
Size=64
Context=Status
Type=Scalable
MinSize=22
MaxSize=256

Adding support for them would improve Awesome's icon theme support a lot, but it may prove incompatible with the old menubar.utils.lookup_icon_uncached function.

Elv13 commented 3 years ago

Semi duplicate of: https://github.com/awesomeWM/awesome/pull/2090 My config has also code to re-use the GTK implementation to load the icons, which isn't affected by this bug.

Using the cache is indeed a lot faster. But it has portability issues (it relies on external mechanisms to keep the cache up-to-date). As for using the GTK APIs, it is at risk of randomly bricking AwesomeWM if GTK make certain "enhancements", so we didn't merge that either.

However, as for implementing index.theme within the current implementation, it could be done. Right now, this is a little bit of a mess because there is many icon lookup implementations scattered around AwesomeWM codebase. This is the result of never having a proper API and people doing drive-by contributions which diverged over time. At some point, someone could clean this up and implement the spec properly, but right now I don't think any of the core contributors have enough time.

ArtyIF commented 3 years ago

Right now, this is a little bit of a mess because there is many icon lookup implementations scattered around AwesomeWM codebase.

I thought it's only menubar.utils.lookup_icon_uncached. Weird.