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:

8 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

Leave a Reply