Setting a custom Gtk theme for specific applications

July 13, 2008

I’m not entirely sure why you’d want to use this, but it does get asked from time to time: How can you use a different Gtk theme, icon theme and/or fonts for specific Gtk applications?

If you just want to change the Gtk theme, you can launch your application with the following command:

GTK2_RC_FILES=/path/to/your/theme/gtkrc application-command

Thus “GTK2_RC_FILES=/home/urukrama/.themes/royalty/gtkr-2.0/gtkrc thunar” will use the Royalty theme for Thunar. Note that this will use the default font and icon theme, not the icon theme or font you specified in your ~/.gtkrc-2.0 or ~/.gtkrc.mine file.

If you’d also like to set a custom icon theme and font for the application, create an empty file, wherever you find convenient (for example in /home/USERNAME/.themes) and call it whatever you want (for example, custom.gtkrc). Then add the following to that file:

#To set the Gtk theme
include "/path/to/your/theme/gtkrc"

#To set the icon theme
gtk-icon-theme-name = "GnomeCorsair"

#To set the font
style "Sans"
font_name = "Sans 8"
widget_class "*" style "Sans"
gtk-font-name = "Sans 8"

Change ‘GnomeCorsair’ to the icon theme you’d like to use, and “Sans” to the font you prefer. The /path/to/your/theme/gtkrc is what it says (for example /home/urukrama/.themes/royalty/gtkr-2.0/gtkrc). If you would only like to have a custom icon theme or font, only specify those and leave the rest out.

To launch Thunar with these settings, use the following command (If you saved the file elsewhere, adjust the path accordingly):

GTK2_RC_FILES=/home/USERNAME/.themes/custom.gtkrc thunar

If you want to use this in a launcher such as Openbox’ menu, rather than the terminal, try the following:

bash -c 'GTK2_RC_FILES=/path/to/your/gtkrc application-command'

I haven’t managed to get this working with either the gnome-settings-daemon or the xfce-mcs-manager running. It seems they override this.

As proof that this works, here is a screenshot of two instances of Mousepad running, one using the default theme, the other launched with a custom gtkrc:

39 Responses to “Setting a custom Gtk theme for specific applications”

  1. volante said

    thank you, for me this is very useful

    i like black themes, but icon in firefox are awful with that themes

  2. 3ark said

    Yes, this is often used by people who enjoy dark themes. Its a great work around for things like OpenOffice which will force the ugly high-contrast icons into use on dark themes. This blog is incredibly useful by the way, keep it up!

  3. Daniel Añez said

    it doesnt work for me :S i have linux mint6 and open 3.0 and i tried those steps! maybe it doesnt work in the latest version of gnome?
    look at the command of the launcher i made:

    bash -c GTK2_RC_FILES=/home/daniel/.themes/Shiki-Wise/gtk-2.0/gtkrc openoffice.org3 -writer

    and i get get the same openoffice window with my blue-joy theme and the ugly high-contrast look =/

  4. Daniel Añez said

    i guess you dont have the time to answer =/

  5. urukrama said

    I’m not sure this works with OpenOffice, which isn’t really a GTK application (but emulates GTK).

  6. Edu said

    Thanks you, it work with OOo but only with some themes.

  7. @ Daniel Añez:
    Your command will work when you add the missing quotation marks.

  8. daspostloch said

    Hi urukrama, thanks, this would actually solve a lot of problems with small apps and my dark theme for me. However, I think I’m in the gnome-settings-daemon case.
    At least it doesnt work for me and I set my gtk theme via
    System->Prefs->Look and feel->appearance under Fedora/Gnome. So do you know another way to set a gtk theme, circumventing this gnome setting thing?
    Thanks, dpl

  9. tscheka said


    i posted a bug report a while ago on this.

    openoffice would have pretty much use for this, afaik. is there any way making theme exceptions for Qt, btw?

  10. […] The solutions was to use a custom GTK theme and setting this using an applications specific GTK setting [ref]. […]

  11. Rockadoodle said

    Hi, i found this article and it is nice.

    is there any chance to do this under gtk3???

  12. how can i use dark adwaita for inkscape?

  13. xkr47 said

    In my experience, the procedure by which the theme is chosen in GTK-2 is as follows:

    1. If defined in GConf (gtk2) or GSettings (gtk3), use that one
    2. Otherwise, if GTK2_RC_FILES is set, use that one
    3. Otherwise, if $HOME/.gtkrc-2.0 is found, use that one
    4. Otherwise, use default theme (whatever that is)

    So if GConf or GSettings has been set to some valid theme, GTK2_RC_FILES has no effect.

    So in order to be able to do theme override, we need to
    a) get rid of the theme in GConf/GSettings
    b) create a $HOME/.gtkrc-2.0 instead to set the user’s default theme
    c) then we can use GTK2_RC_FILES to override the theme

    So, let’s do this!

    If we used one of the regular system themes, they are probably found in /usr/share/themes/. Let’s say we want to use the Crux theme by default. This is one way to do it:

    ln -s /usr/share/themes/Crux/gtk-2.0/gtkrc $HOME/.gtkrc-2.0

    Then we clear the theme setting in GConf or GSettings, using either of the following commands:

    gtk2: gconftool-2 –set /desktop/gnome/interface/gtk_theme –type string “”
    gtk3: gsettings set org.gnome.desktop.interface gtk-theme “”

    Hopefully this helps.

    If things get messed up due to my instructions, just remove the $HOME/.gtkrc-2.0 file and use your favourite theme selection tool to restore the theme setting or alternatively one of the following commands:

    gtk2: gconftool-2 –set /desktop/gnome/interface/gtk_theme –type string “Crux”
    gtk3: gsettings set org.gnome.desktop.interface gtk-theme “Crux”

    Good luck! 🙂

  14. Morgen said

    Hmm, I have the gsettings and gconftool-2 values set and it still works flawlessly for me.

    Thanks for this! Gnuplot with a dark background is a pain in the neck to see what’s going on.

  15. kerenskyy said

    i’m interested in this b/c latest tixati either freezes or evaporates when using oxygen-gtk.

  16. coderz4life said

    > I’m not entirely sure why you’d want to use this, but it does get asked from time to time: How can you use a different Gtk theme, icon theme and/or fonts for specific Gtk applications?

    One reason for me: Eclipse. It uses the system colors for stuff like tooltips, but for some reason, renders it badly. In my case, setting Eclipse to not use system colors does not work. So, the only other option is to customize the theme. Eclipse 4.2 (Juno) supposedly allows all views to be customized, but not upgrading to that heap of crap.

  17. kerenskyy said

    i see now on slackware this is not necessary. wonder what the difference is compared to kubuntu…

  18. Does it work on ubuntu 12.04 ?

    • kkk said

      can’t see why it would not, unless Canonical changed the GTK runtime found in 12.04 to remove it.
      Have you tried it?

  19. Yes. But nothing happened. I have tried different themes, but without success. In ubuntu 10.04 – 10.10 it works.

    • jeckyl said

      I’m using kubuntu 12.10. Tixati, ( a gtk software), freezes when using oxygen-gtk theme so I use “GTK2_RC_FILES=/usr/share/themes/Nodoka-Squared/gtk-2.0/gtkrc tixati” to launch the program. And it consistently works so far.
      Additionally, after entering “GTK2_RC_FILES=/usr/share/themes/Nodoka-Squared/gtk-2.0/gtkrc” in konsole & pressing Enter, should i type “filezilla” in konsole and hit Enter, Filezilla launches using Nodoka-Squared theme.

      What happens if u use “/usr/share/themes/Raleigh/gtk-2.0/gtkrc” ?

      Sorry I can’t be more help. Best of luck!

  20. ngolo said

    this doesn’t seem to be needed on up to date fedora core 18 when using tixati. nice.

  21. I’m using ElementaryOS Luna, and I would really really like a better theme than this high-contrast ugly one in Audacity. Does this work? I haven’t tried, because it looks very complicated, and I would have to spent much time on it, so if I could just have som,eone confirm it works in EOS… thanks.

  22. […] got this from here, which has some additional information about more complicated […]

  23. […] got this from here, which has some additional information about more complicated […]

  24. […] got this from here, which has some additional information about more complicated […]

  25. […] be a problem. (here) There is also a blog post detailing this method a little more. (here) and (here). There is also a similar question on this site that has already been answered. […]

  26. AN said

    This is invaluable for Libreoffice. It allows you to have a consistent font size in menus and dialogs, which libreoffice doesn’t try to do by default. Thanks so much!

  27. ebola said

    It’s very nice help also a long time after the original topic! But have a problem where maybe somebody could help me.

    I tried to make a custom .gtkrc file with Adapta-Nokto theme (which is basically a dark version of the original Adapta theme). I put the basic GTK theme, and also the required ‘light’ icon theme (which is Papirus-Dark-GTK) in the file. The whole thing is because I need dark theme for Inkscape and Gimp.

    When I pull these applications with this custom .gtkrc file the success is just half. I get fully light icons (what I wanted) but just with half way applied dark theme. The select boxes are dark and some others also, but the 70% of the applications still use the same light theme.

    Could anybody help me, or test it for me maybe? With the settings above could be our desktop environment totally a modern and nicely applicable for graphical works.

    Thanks in advance!

  28. […] How to open a single GTK+3 program with a different icon theme? I’ve only found a solution for GTK+2. […]

  29. Lew Rockwell Fan said

    Nice post. I tried this with viewnior and it worked for colors but I lost control of my font sizes, which presumably come from themerc. Is there a solution to this?

    I think we could also individually theme any app by creating a user account for it and invoking it with sudo -u newuser -H. You’d have to tell the x server with xhost also.

  30. Lew Rockwell Fan said

    Darn, I wish I could edit that ^. Musta got my stoopid pills confused with my smart pills. I see it now.

  31. Lew Rockwell Fan said

    This is GREAT. Anyone know how to do this with the Openbox theme? Specificially, themerc? I want to change border colors on a specific application. It comes from this kind of statement in themerc:
    border.color: #000000

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: