How to override GTK3 / Gnome Shell themes per application

cinnamongnome-shellgnome3libreofficethemes

I'm using both Cinnamon and Gnome Shell (Gnome 3) on Fedora 17 with the dark theme Blapple. Quite a few applications can't handle dark themes very good.

In Gnome 2 I had a simple solution for these programs. I just instructed them to use a light theme via the environment variable GTK2_RC_FILES like the following (example worked in some 2009 Ubuntu Gnome 2 setup):

env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc ooffice --writer

Now in Gnome 3 that doesn't work. I tried it in a lot of different variations of command like the following, without success so far:

env GTK2_RC_FILES=/usr/share/themes/Adwaita/gtk-3.0/gtkrc GTK3_RC_FILES=/usr/share/themes/Adwaita/gtk-3.0 libreoffice --writer

I can't find documentation about this anywhere. If you know how to do it or where I could get that information, please tell me.

Why override at all: In case of LibreOffice and OpenOffice trying to work around the problems seems useless. When the Blapple theme is installed, everything has a gray background. Trying to override the default background color in Calc for example makes the background white, but also overrides each and every custom background cells to be white, which is horrific. Don't let me start about how nice Impress works…

Best Answer

I have got the same problem, OpenOffice + black theme looks ugly. Is seems there's nothing which is as convenient as the old GTK2_RC_FILES variable, but take a look at this:

An application can cause GTK+ to parse a specific CSS style sheet by calling gtk_css_provider_load_from_file() and adding the provider with gtk_style_context_add_provider() or gtk_style_context_add_provider_for_screen(). In addition, certain files will be read when GTK+ is initialized. First, the file XDG_CONFIG_HOME/gtk-3.0/gtk.css is loaded if it exists. Then, GTK+ tries to load HOME/.themes/theme-name/gtk-3.0/gtk.css, falling back to GTK_DATA_PREFIX/share/themes/theme-name/gtk-3.0/gtk.css, where theme-name is the name of the current theme (see the "gtk-theme-name" setting) and GTK_DATA_PREFIX is the prefix configured when GTK+ was compiled, unless overridden by the GTK_DATA_PREFIX environment variable.

Source

This means that by doing this, you force GTK to use the default plain theme:

env GTK2_RC_FILES= GTK_DATA_PREFIX= libreoffice --writer

There doesn't seem to be a possibility to override the theme name (which is a bit stupid and should be fixed), so it seems the only way would be to create a "fake" theme directory.

Related Question