How to use a different theme for individual applications

:warning: This tip works for GTK2 or GTK3 themes and applications. This post does not cover applications based on other toolkits, such as Qt.


GTK2 Applications

As an example, I'll use the text editor, pluma, which is based on GTK2 in 16.04.

For system-wide themes:

env GTK2_RC_FILES=/usr/share/themes/BlackMATE/gtk-2.0/gtkrc pluma

For locally installed themes:

env GTK2_RC_FILES=$HOME/.themes/BlackMATE/gtk-2.0/gtkrc pluma

GTK3 Applications

As an example, I'll use the disk utility, gnome-disks, which is GTK3 in 16.04 and beyond. Software pre-installed in 16.10 onwards are built against GTK3.

env GTK_THEME="BlackMATE" gnome-disks

The Result

Pluma now matches the dark syntax theme -- more pleasing to the eyes. :sunglasses:


If you need a guide on making this persistent and identifying themes, keep reading.

Which theme?

First, make a note of which theme you'd like to use for that specific application and find the directory name associated for it.

You can see your locally installed and system wide themes in Preferences → Look & Feel → Appearance. Any themes you download can be stored in ~/.themes or installed to /usr/share/themes for all users.


Update the Launcher / Main Menu

Before we start committing to this theme, check that it works in the terminal as expected.

Not all applications are based on GTK, but many programs like pluma, libreoffice, geany, inkscape, gimp are, just to name a few. Beware that GTK2 and GTK3 applications differ slightly in their behaviour and appearance.

All good? Right-click the main menu and select Edit Menu.

Double click the application and paste the env section of the command to the start. Ensure you start with env (which is setting an environment variable for that application) and not accidentally delete any arguments (which passes your files)... or the command itself.

That's all. Specific programs can use different themes to the rest of your session.

Have fun customizing your system! :smile:


:thumbsup: Thank you to this answer on askubuntu.com

7 Likes

Maintainer of the OS learns something :open_mouth:

5 Likes

I have an issue with this - pluma was not giving me BlackMate (even BlackMATE was copied in .themes folder)
Problem is that the path to home folder was interpreted as: /home/home/username, so to made this functional just modify this to:

env GTK2_RC_FILES=/$HOME/.themes/BlackMATE/gtk-2.0/gtkrc pluma (remove first "home" in path)

Regards,
Vlada

1 Like

Oops, thanks for pointing that out @vlajkom . /home/$USER/ would have worked too. I’ve amended this on the post.

1 Like

Thank you so much, I confirm that this works with Kdevelop 5, which is a QT5 application I thought!

Was directed here because I'm trying to do this with Caja, since I prefer a system dark theme and a light theme for Caja. Does this still work in Ubuntu-Mate 22.04.3 LTS? Because I'm not having much luck with it and I don't know if it is due to changes in how the theming works or how GTK3 works.

Thanks.

The trick still works in 22.04! Caja is a bit awkward because it is always running, so running caja again speaks to the existing instance, which doesn't have the variable set.

To make it work, edit the Caja menu entry which has a command exactly /usr/bin/caja (there's a couple in Other). Prepend the theme variable like so:

env GTK_THEME=Yaru-MATE:light /usr/bin/caja

Then log out and log back in!

Should note that if you start apps/scripts from Caja, they'll use the light theme, since it inherits that GTK_THEME variable. Modern GTK themes usually label them like Yaru-MATE:light and Yaru-MATE:dark.

2 Likes

I'm afraid I'm doing something wrong somewhere because that's just not working for me. I did log out and then when that didn't work I did a complete restart to be sure that things had loaded out of memory.

Thanks any way.