Set up GTK application icons on KDE

Posted by | Comments (2) | Trackbacks (0)

Gnome and KDE come more and more together but there are still some differences which sometimes might lead to incompatibilities between these two large desktop environments. Whereas you have relatively few problems with KDE applications on Gnome there are far more problems when using Gnome applications on KDE. But what's the difference between Gnome applications and KDE applications? In general it's the UI library they use. Gnome uses GTK and KDE uses Qt. Both are very common and flexible GUI frameworks used for a wide range of desktop applications. Which one is the best? I don't know, there is a great argue about that but it's a more religious war than a discussion based on facts. In my opinion both have advantages and disadvantages and one great disadvantage is the bad compatibility between the two even though there are some compatibility engines.

So what to do first? When you have set up your KDE system from scratch GTK applications will look horrible. Their boxy look has the rough taste of the early 90's not to say it looks very outdated. To get rid of this ugly look you can either install gtk-chtheme which is a GTK stand-alone theme changer or you can install gtk-qt-engine (might be named gtk-engines-qt in your package manager) which provides an option in your KDE system settings that lets you configure the look of GTK applications. That also provides a theme called Qt4 which you can use but without a lot of extra work this looks slightly ugly. Thus on my system I use Clearlooks Compact which (with KDE color settings) integrates pretty well into my Oxygen interface with one exception: the icons in GTK applications especially in file open/save dialogs are not those of my Oxygen icon theme by default.

On most graphical systems you have GTK as well as Qt programs and even if you use a distribution whose maintainer has already done the integration work for you you'll still see which one is GTK and which one is Qt since it's nearly impossible to give them a uniform look. In this Howto Blog post I'll show you a way to converge GTK and Qt as much as possible from the perspective of a KDE system.

The following image gives you an impression how Clearlooks Compact looks like on KDE by default when you don't do some hand work:

Ugly default icons in Firefox' file open dialog

You see: there are just the default icons which are exactly two: one generic folder icon and one generic file icon. That's pretty ugly and the icons do not correspond to the file type. But what to do?

What we did before was setting the theme for GTK applications on a graphical way but now let's go deeper into GTK's configuration. In your home folder you should find a file named ~/.gtkrc-2.0 or ~/.gtkrc-2.0-kde4. .gtkrc-2.0 is generated by gtk-chtheme and .gtkrc-2.0-kde4 by gtk-qt-engine. Open one of these files in the editor of your choice, mine is vim. There you see what you've set using your graphical tool. E.g:

# This file was written by KDE
# You can edit it in the KDE control center, under "GTK Styles and Fonts"

include "/usr/share/themes/Clearlooks Compact/gtk-2.0/gtkrc"

style "user-font"
        font_name="Sans Serif"
widget_class "*" style "user-font"

gtk-theme-name="Clearlooks Compact"
gtk-font-name="Sans Serif 8"

First you see an include directive which includes the GTK theme, here Clearlooks Compact. The next directives specify the font used then the theme's name and lastly the font style and size. That's the setting for your GTK theme. What we need to specify is the icon theme used. We do this using the directive


for the Oxygen icon theme. But hold on! We can't write it into this file since it'll be overwritten next time you use the graphical tool. So what to do? That's quite easy. We need to use our own configuration file. Therefor copy the file which contains the right settings for you to a name you like, e.g.:

cp ./.gtk-2.0-kde4 ./.gtk-2.0-custom

Then insert the above line. If you like you can also override the fallback icon theme which is originally defined at /etc/gtk-2.0/<arch>/gtkrc whereupon <arch> is either x86_64-pc-linux-gnu or i686-pc-linux-gnu depending on your system's processor architecture.

gtk-fallback-icon-theme = "oxygen"

Save the file. Next add this file to the $GTK2_RC_FILES environment variable. Environment variables for KDE sessions are defined in ~/.kde4/env/ therefore add an export command to a file in this folder:

echo 'export GTK2_RC_FILES="${GTK2_RC_FILES}:${HOME}/.gtkrc-2.0-custom"' >> ~/.kde4/env/

or edit the existing directive in this file. If contrary to expectations this file does not already exist make sure you give it execution rights. To make this setting system-wide available create a file in /etc/kde/startup/ instead (also with execution rights). If you're not using a graphical login manager you could also use your .xinitrc for this purpose.

You're now done. The environment variable change will now be available for new KDE sessions. Therefore to see the changes you have to re-login but you can also test this in your current shell by manually exporting the variable. For this purpose run the export command in a terminal window and start a GTK application from there. When you open a file dialog it should look like this:

Firefox' file open dialog with Oxygen icons

But you'll notice that the buttons still have Gnome icons. That's because the Gnome theme has some icons the Oxygen theme doesn't have (with that name). These are all the files named gtk-* in the <size>/actions folder of your gnome icon set. These are used for the GUI itself (toolbars, dialogs, buttons etc.). The Oxygen theme has all these icons but not under this name. I've written a shell script for you which copies all the necessary Oxygen icons to the needed gtk-* named files. To use it pass the path to an Oxygen (!) action icon folder to this script (e.g. /usr/share/icons/oxygen/32x32/actions) and it will create a folder named gtk_icons_extracted in your current working directory with the new icons. You can then move these icons to your Oxygen's action folder. Now you should have Oxygen icons in your GTK applications. To see an effect for currently running applications you have to restart them.

When you're done restart your X session and enjoy!


No Trackbacks for this entry.


There have been 2 comments submitted yet. Add one as well!
Coacher wrote on : (permalink)

Your article is good, but well known for me. But you script is awesome! Thamks a lot. Is there any hope you will maintain it?

Janek Bevendorff
Janek Bevendorff wrote on : (permalink)

Hi Coacher,

thanks for your comment. Currently, I’m using a more recent version of QT curve, so an update wouldn’t be of much use for me, but perhaps I’ll provide an updated version some day. You can also create one yourself. It’s not that hard. Just have a look at the gnome icons folder and add or modify the copy rules in the script accordingly.

Write a comment:

HTML-Tags will be converted to Entities.
Markdown format allowed
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

By submitting a comment, you agree to our privacy policy.

Design and Code Copyright © 2010-2021 Janek Bevendorff Content on this site is published under the terms of the GNU Free Documentation License (GFDL). You may redistribute content only in compliance with these terms. tweetbackcheck