apgoetz / jolly

Apache License 2.0
12 stars 3 forks source link

Icons don't work on NetBSD without setting env var $XDG_DATA_DIRS #21

Open apgoetz opened 1 year ago

apgoetz commented 1 year ago

Support for icons in Jolly on Linux and BSD has been added recently in #20 . Unfortunately, this support does not work by default on NetBSD. This is because Jolly uses crates to implement icons that assume that icon themes and xdg-mime data is available in the standard XDG folders.

Jolly depends on the crates freedesktop-icons and xdg-mime to implement icon support for Freedesktop based platforms. These crates check the environment variable $XDG_DATA_DIRS to determine where to look for icons and mime types, but if this environment variable is not set, then they default to the official default value from the standard:

from freedesktop.org:

If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.

On most platforms, this works ok, because most platforms install icons and mime info in one of these folders, However NetBSD is special: it defaults to installing package files in /usr/pkg, which does not appear in the default XDG search path.

Therefore, it makes sense to add a way to specify additional folders to search with $XDG_DATA_DIRS, in case the default values specified by the standard are insufficient.

Ideally, the upstream packages that Jolly depends on would implement a way to specify "additional XDG_DATA_DIRS", and then Jolly could use these functions to inform the crates where to search.

Since that might take a while to implement, as a workaround, Jolly could modify the XDG_DATA_DIRS environment variable at startup, before calling into the supporting crates. We could use a build-time environment variable, for example, JOLLY_EXTRA_XDG_DATA_DIRS to configure this functionality.

Alternatively, we could have a config variable in jolly.toml that specifies additional paths to search. However, this requires users to add this to their config file whenever they need a different XDG search path, but the search path for icons and mime types is not likely to be changed, so it might make more sense to set it as a compile time option.