GNOME Bugzilla – Bug 641354
Look for themes in XDG folders
Last modified: 2016-03-22 09:42:24 UTC
Right now _gtk_css_provider_get_theme_dir only looks at GTK_DATA_PREFIX and doesn't honor XDG folders, ie. g_get_system_data_dirs(). See http://git.gnome.org/browse/gtk+/tree/gtk/gtkcssprovider.c#n4134
What I am missing here is an explanation of why it would be a good idea to look for themes in more places
Moving data out of the home directory is a good thing. It makes it easier to migrate data and allows one to relocate configuration data to even remote storage.
*** This bug has been marked as a duplicate of bug 447840 ***
Hmm I think I misunderstood.
Actually, we already look in XDG_CONFIG_HOME/gtk-3.0/gtk.css. The code for this is in http://git.gnome.org/browse/gtk+/tree/gtk/gtksettings.c#n1538 It would be good to test that this works as intended.
I think GTK should look for themes in all directories in XDG_DATA_DIRS as Christian originally suggested. That way I could install a theme locally (e.g. in /usr/local/share/themes or ~/local/share/themes) and GTK could still find it.
Matthias, would you take a patch to look for themes in all XDG_DATA_DIRS?
Hey there! I've come to this bug report after dealing with the need to have XDG_DATA_DIRS support in GTK+. In a system with a functional package manager like GuixSD or NixOS, everything outside of ~/home is generally immutable. Furthermore, these systems aren't FHS-compliant as each package lives in its own directory in what we call 'the store'. Installing a theme system-wide, it'd most likely end up in /run/current-system/profile/share/themes. But we also have ways for users to install packages in their own profiles, which usually can be found in ~/.guix-profile/share/themes. As a result we have no single location for themes. I wrote a long discussion about our options for fixing this in GuixSD: https://lists.gnu.org/archive/html/guix-devel/2016-03/msg00492.html It includes some patches that may be appropriate here, but I'd have to extract them from the Guix tree for you. Luckily, XDG_DATA_DIRS covers those paths above and is also customizable by the user in case they want to try themes in a sandbox before installing it to their profile. In fact Xfce already reads this directory when looking for themes! It'd be much appreciated if GTK+ started looking at XDG_DATA_DIRS for themes, it'd fix the issue in GuixSD and NixOS. It'd also mean people using Guix or Nix on other distributions would be able to use installed themes in those package managers.
Created attachment 324151 [details] [review] Also look in system data dirs for themes With this change, we now look in $XDG_DATA_HOME/themes/THEME/gtk-3.x $HOME/.themes/THEME/gtk-3.x $XDG_DATA_DIRS/themes/THEME/gtk-3.x GTK_DATA_PREFIX/themes/THEME/gtk-3.x
Created attachment 324152 [details] [review] Load theme settings from the right location When loading a per-theme settings.ini file, look for it in the same directory where we found the gtk.css file for the theme. Previously, we were always looking in $prefix/share/themes/THEME/gtk-3.0/, even if the css was loaded from somewhere else.
Review of attachment 324151 [details] [review]: .
Attachment 324151 [details] pushed as 475d916 - Also look in system data dirs for themes Attachment 324152 [details] pushed as 7cb36ab - Load theme settings from the right location
Wow, thanks for the fast response and fix! One thing I'd like to note is that the inspector also looks for themes, perhaps this could cause some confusion since it's not patched? Jookia.