Getting system theme colors without using GTK / Qt libs
pcman.tw at gmail.com
Thu Jul 18 01:02:20 PDT 2013
On Thu, Jul 11, 2013 at 4:49 PM, Krzysztof <dibo20 at wp.pl> wrote:
> 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?
There're no standards for this, but you can do it perfectly without
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:
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
It takes some time.
More information about the xdg