Query XSettings Manager for Icon Theme

819 Views Asked by At

I'm writing an Application in Vala (a c compatible language) for which I need the icon theme that is currently set.
I want to avoid having GTK+ or Qt as an dependency.

I know that GTK+ 3 has a settings.ini and GTK+ 2 has a .gtkrc-2.0 file, but according to this those files are only fallbacks in case no XSettings Manager is running.

I tried to find some informations about XSettings Manager and it seems that XSettings is only a specification that gets implemented by desktop environments. The most popular implementation is probably Gnomes gnome-settings-daemon but there are others like lxsettings-daemon (integrated in lxsession) in LXDE or xfsettingsd of XFCE.

Now I need to find out how to query the XSettings Manager for the value of the Net/IconThemeName key.

I found this specification, but I dont quite understand it. (I have never worked with Xlib before)
Is this what i need ?


To be clear: I don't want to implement the XSettings Manager spec, but I want to query the currently running implementation for the currently set icon theme.

Can somebody please help me understand the spec? It seems rather confusing to me.

Or am I doing it completely wrong ?

2

There are 2 best solutions below

1
On BEST ANSWER

There's a library called libxsettings-client that provides a C interface for accessing XSettings. You'd need to port the API to Vala, which looks pretty straight forward given how small it is (<70 lines). It would depend on x11.vapi, which is already included with Vala. Have a look at binding legacy APIs for information on how to port it.

1
On

You can just spawn dump_xsettings command from xsettingsd package ( I believe libxsettings-client is part of it ). I believe gnome-settings-daemon and unity-settings-daemon expose dbus interface as well, but if you want to be xsettings manager agnostic you really need to read value from _XSETTINGS_SETTINGS property of _XSETTINGS_S0 owner and parse result ( manually or via libxsettings ). The format is not actually that complex, but you should keep in mind that all keys are stored in single window property and you read and decode all of them ( and if you want to change one, you need to serialize back ALL keys )