Gtk2 and Gnome2 Applications Outside Gnome2

Many users by now have figured out that for Gtk1 applications, regardless of the window manager or desktop you are using, you need only have a copy of your favorite theme's gtkrc file in your home directory, and name it ~/.gtkrc. For Gtk1, this is a file that contains instructions on the colors to use for the applications that are built on the Gtk1 libraries.

Gtk2 is a little more complicated. Two issues show up a lot on the lists about getting Gtk2/Gnome2 applications to display correctly when not running Gnome2. As often happens with Gnome in general, and especially in SuSE, the answers are poorly documented, if at all.

Fonts: Create a config file in your home directory -- ~/.gtkrc-2.0. In this file, place one simple line:

   gtk-font-name = "Arial 12"

You can choose any font that is processed by Xft (see Font Fight for details on that), using the capitalized name and point size that suits you.

Theme: To get the color scheme you like, choose one that is available on your system -- /usr/share/themes in SuSE -- and make sure it is indeed Gtk2, as not everything there is. You can also download and install your own in ~/.themes. As root, make a soft link ("s-link") from that folder name (mine is "/Dirty-Ice") to /opt/gnome2/share/themes/ and name it "Default". If you have multi-users on your system, be aware that it will affect them, too.

The command line would look like this:

   ln -s /usr/share/themes/[theme] /opt/gnome2/share/themes/Default

For a single user, go back to your ~.gtkrc-2.0 and add a line like this one:

   include "~/.themes/Dirty-Ice/gtk-2.0/gtkrc"

Of course, you have to match the details to the actual location of the theme you wish to use. Be sure to list the full path to the gtkrc file. It can reference any Gtk2 theme on your system.

Recent popular distros have begun adding undocumented tweaking to ensure that your are virtually forced to use their particular favorite Gtk theme and widget set. In SUSE, it was necessary to edit the startkde script to turn it off. In Mandrake, it was simply a matter of insuring that your ~/.gtkrc referenced a theme engine (widget set) that existed on your system. For the ~/.gtkrc-2.0 it was similar, in that the engine in the gtkrc for Gtk2 themes had to be present for the theme you referenced.


By Ed Hurst, update 01 January 2003
This document has been released into the public domain.