How to override GTK3 / Gnome Shell themes per application

Solution 1:

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.

Solution 2:

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.

Solution 3:

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.