Detect default gtk3 theme
I packaged up a small C utility
written by an enterprising user at Stackoverflow. This is a small utility that
makes it easy to discover what the current default theme is for gtk3. Patches
are welcome for providing support for other versions of gtk. I also added a
python3 implementation because, one shouldn't always need a C compiler for
something so basic. I decided to package this up, because
reading ~/.gtkrc-2.0 or ~/.config/gtk-3.0/settings.ini should be
a oneliner! Plus, I can never have too many packages of my own. You should run
these programs with stderr redirected to null (i.e., 2>/dev/null
) if your
theme causes Gtk minor indigestion.
Code
The entire C program follows.
#include
#include <gtk/gtk.h>
int main() {
gchar *prop;
gtk_init(0, 0);
g_object_get(gtk_settings_get_default(), "gtk-theme-name", &prop, 0);
return !printf("%s\n", prop);
}
It is worth noting that the original author uses pkg-config to select all the include paths for the linker. Go read the Makefile for the details of that. The python program follows.
1 2 3 4 5 6 |
|
References
Weblinks
- C version lifted entirely from linux - GTK2 vs. GTK3: detect GTK3 theme in bash script - Stack Overflow
Comments