11

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…

2
  • GNOME Shell uses GTK3 - not GTK2
    – fpmurphy
    Jan 1, 2013 at 15:09
  • I know that. I tried both.
    – aef
    Jan 3, 2013 at 12:19

3 Answers 3

8

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.

7

I know this is a very old question but this is how to do it in GTK+3.

GTK_THEME=Adwaita gnome-calculator

or use

GTK_THEME=Adwaita:dark gnome-calculator

for the dark variant of Adwaita theme.

1
  • Nice find; this works for gnome-calculator but doesn't work for all applications :(
    – Ninj0r
    Sep 2, 2018 at 12:32
2

Working solution for GTK3+:

Create custom .desktop file in ~/.local/share/applications/, you can copy it from /usr/share/applications/

Edit it and modify the "Exec=" line, append "env GTK_THEME=" after the "=", so it looks like this:

Exec=env GTK_THEME='Numix Daily' /usr/share/dbeaver/dbeaver

For convenience, change the "Name=" to something else:

Name=DBeaver Community (Numix theme)

Then, run update-desktop-database.

My example here is for DBeaver, but I've tested it with Libreoffice Writer and it works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .