whitequark / rust-xdg

A library that makes it easy to follow the X Desktop Group specifications
https://wiki.freedesktop.org/www/Specifications/
Apache License 2.0
145 stars 29 forks source link

Feature Request: Icon Themes #29

Open bollian opened 4 years ago

bollian commented 4 years ago

I'm currently running into an issue in a personal project of mine where I want to load icons based on the user-selected theme, but there don't seem to be any good rust crates for doing this. Could this crate accommodate this use-case, given that it's an XDG standard (https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html)?

I don't expect this library to load the images itself. I'm more interested in locating icon file paths by name, and potentially implementing the caching rules discussed in the standard.

I didn't notice anything in the above link specifying exactly where the name of the icon theme is stored, so that might be a barrier to implementation, but seemingly neither GTK or Qt have a problem with this.

whitequark commented 4 years ago

This is in scope for the xdg crate, and I encourage you to contribute the code to do that.

bollian commented 4 years ago

So I'm definitely willing to work on this. After looking into it further, implementing this is going to require the ability to parse desktop entry files (https://specifications.freedesktop.org/desktop-entry-spec/latest/). I did find the ini crate out there, but I think the desktop entry specification has enough special stuff in there to justify rolling a specialized parser.

It's actually a semi-interesting problem. The .theme icon theme files, along with the other iterations of desktop entry files, all seem to follow the same format, but have different schemas. It'd be nice to have a single parser that can then be applied to all the different use-cases.

whitequark commented 4 years ago

I agree that a specialized parser makes sense here.

TimTheBig commented 1 month ago

How about a feature flag for xdg icon-theme that will use a separate module to parse the theme files. The theme path should be in the default crate.