Getting system theme colors without using GTK / Qt libs

PCMan at
Thu Jul 18 01:02:20 PDT 2013

On Thu, Jul 11, 2013 at 4:49 PM, Krzysztof <dibo20 at> wrote:
> Hi,
> I need to get system theme colors (like text color, selection color, window
> color etc). Can I get it without use GTK/Qt API? Have freedesktop some
> standard for that?
> Regards

There're no standards for this, but you can do it perfectly without
both toolkits.

For gtk+:
1. Try xsettings first, gtk+ 2 and 3 expose color settings via
xsettings. Read gdk source code to see how it's done.
2. If xsettings daemon does not exist, read and parse ~/.gtkrc-2.0 or
whatever equivalent file for gtk 3 (I forget the exact file name). If
color settings are not defined in the rc file, try to get the theme
name, and read directly from the theme definition file.

For Qt without KDE:
Read ~/.config/Trolltech.conf

For Qt under KDE:
I'm not sure, KDE styles might do other stuff not defined in standard
Qt or override some Qt config values with KDE ones.

I'm sure this works, but the format of gtk+ 2, gtk+3, Qt, and KDE are
all different.
It takes some time.
Good luck!

More information about the xdg mailing list