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:

About these ads

34 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

    http://img261.imageshack.us/img261/9724/firefoxnegrobk5.png

    http://img261.imageshack.us/img261/6800/firefoxblancovk5.png

  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 office.org 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

    hi,

    i posted a bug report a while ago on this.

    http://www.openoffice.org/issues/show_bug.cgi?id=106620

    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

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

  16. > 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

      Hi,
      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. cake uv said

    This website was… how do I say it? Relevant!! Finally I’ve found something that helped me.

    Cheers!

  23. Heya i’m for the first time here. I came across this board
    and I in finding It truly useful & it helped me
    out much. I am hoping to present something back and help others such as
    you helped me.

  24. Ronald said

    One must practice the comic scripts beforehand at home.
    For more information on my Workshops, Writing Mastermind Groups and
    private coaching, please go to my website listed below
    and feel free to call me any time. Do some research and find out as much as you can about each open
    mic – try to find the one that is most positively reviewed,
    gets the biggest crowd and that is attended by the most comedians.

  25. You have to impress homebuyers and give them a glimpse of how their lives
    could be if they live in your house. It’s not a well-known fact
    but there are several choices of listing agreements available, not just the standard form your broker usually
    provides when you list your house. * Place TVs, stereos and other electrical items in the northeast part of your home.

  26. Wonderful blog! I found it while browsing on Yahoo
    News. Do you have any suggestions on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there!
    Cheers

  27. Simply want to say your article is as astounding.
    The clarity in your post is just cool and i could assume you are an
    expert on this subject. Well with your permission let me to grab your RSS feed to keep updated with forthcoming
    post. Thanks a million and please continue the enjoyable work.

  28. Hi there, I found your site by way of Google even as searching for a comparable topic, your website got here up, it seems to be good.
    I have bookmarked it in my google bookmarks.
    Hi there, simply was alert to your blog through Google, and located
    that it’s really informative. I’m gonna be careful for brussels.
    I’ll be grateful for those who proceed this in future. Lots of other folks might be benefited out of your writing.
    Cheers!

  29. Your style is unique in comparison to other folks I’ve read stuff
    from. Thank you for posting when you have the opportunity,
    Guess I’ll just book mark this web site.

  30. Some of these benefits are: increased secretion of HGH, raises the connection between other hormones, enhancing the synthesis of Phosphatidyl Choline to improve
    mental focus and cognition function, improves comes from workouts, improves
    fat removal through the liver to help you prevent obesity and diabetes, and
    cuts down on the probability of heart attack, stroke and Alzheimer’s disease.
    These are common the natural connection between aging, which happens
    because your body slows down producing HGH or human growth hormones.
    A lot in the brands in the market are only regular multi vitamin pills which are packaged as human growth
    hormones supplements.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 79 other followers