5

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 ?

Ansgar
  • 371
  • 3
  • 15
  • What kind of application are you writing that uses the icon theme, but neither Gtk+ nor Qt (nor X11 directly apparently)? Is it a command line tool that does something with the icon theme? Maybe you could have the theme name as a command line parameter? – Jens Mühlenhoff Jun 10 '14 at 20:54
  • I'm writing a library that gets used by an application which uses GTK or Qt (havent decided - I know both). But I want the IconTheme information inside the library. I agree that it wouldn't be impossible to get the information from the application that uses the library. But I want to separate the data from the slow python gui as best as I can. – Ansgar Jun 12 '14 at 01:53

2 Answers2

3

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.

apmasell
  • 7,033
  • 19
  • 28
  • That libxsettings-client could use some work, or at least some comments. I ended up implementing [the code](http://libxsettings-client.sourcearchive.com/documentation/0.17-5/dir_2c2fea91bd7e08e5275e65154a8842df.html) myself in vala. Because I only needed to read the values (and not change them) I was able to compress those 978 lines C into ~120lines vala code. Thanks for pointing me in the right direction :) – Ansgar Jun 12 '14 at 01:43
3

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 )

Andrey Sidorov
  • 24,905
  • 4
  • 62
  • 75
  • btw I wrote javascript serializer/deserializer for xsettings binary data - https://github.com/sidorares/x11-xsettings/blob/master/index.js – Andrey Sidorov Jul 28 '17 at 08:15