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:

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
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!
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 =/
i guess you dont have the time to answer =/
I’m not sure this works with OpenOffice, which isn’t really a GTK application (but emulates GTK).
Thanks you, it work with OOo but only with some themes.
@ Daniel Añez:
Your command will work when you add the missing quotation marks.
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
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?
[...] The solutions was to use a custom GTK theme and setting this using an applications specific GTK setting [ref]. [...]
Hi, i found this article and it is nice.
is there any chance to do this under gtk3???
[...] I found the site below, but the instructions seem a bit outdated and they do not work for GTK3. http://urukrama.wordpress.com/2008/07/13/setting-a-custom-gtk-theme-for-specific-applications/ [...]
how can i use dark adwaita for inkscape?
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!
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.
Thanks!
thnx!
i’m interested in this b/c latest tixati either freezes or evaporates when using oxygen-gtk.
> 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.
i see now on slackware this is not necessary. wonder what the difference is compared to kubuntu…
Does it work on ubuntu 12.04 ?
can’t see why it would not, unless Canonical changed the GTK runtime found in 12.04 to remove it.
Have you tried it?
Yes. But nothing happened. I have tried different themes, but without success. In ubuntu 10.04 – 10.10 it works.
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!
this doesn’t seem to be needed on up to date fedora core 18 when using tixati. nice.
For the novice, the first thing you need to understand is what the term
“Digital Single Lens Reflex” means. ” and for the duration of the take, (s)he is an audience member sitting in the theatre or their couch at home. With the i – Phone you can stay connected anywhere you go, and access maps, flight info, weather reports, restaurants and more in every new city you travel to.
Basically, everywhere where there are lots of people or items that need to be
cooled can benefit from one of the portable air conditioning units available.
While some maintenance can be done by a homeowner,
a good plumber or HVAC technician should be consulted to make
sure that your heating system will run efficiently during the next winter season and for years to come.
” Equipment that is used to measure the saturation of moisture.