5

Some applications can respond live to GTK+ theme changes. For example, Thunar, Geany, lxrandr, Hexchat will all update their UI when a theme is changed, for example in lxappearance. These are all GTK+ 2 programs.

On the other hand, evey GTK+ 3 program I have tried so far (including baobab, moserial gucharmap, ghex, pamac, evince, xreader) seems to not be able to reload the theme and requires an application restart.

lxappearance (compiled with gtk2 on my system) is sending a GTK+ "signal" (not 100% on the terminology here in GTK-land) to cause the application reload:

// src/lxappearance.c line 198
static void reload_all_programs()
{
#if GTK_CHECK_VERSION(3, 0, 0)

/* TODO Port this to something else than gdk_event_send_clientmessage_toall */

#else
    GdkEventClient event;
    event.type = GDK_CLIENT_EVENT;
    event.send_event = TRUE;
    event.window = NULL;

    if( app.use_lxsession )
    {
        event.message_type = gdk_atom_intern_static_string("_LXSESSION");
        event.data.b[0] = 0;    /* LXS_RELOAD */
    }
    else
    {
        /* if( icon_only )
            event.message_type = gdk_atom_intern("_GTK_LOAD_ICONTHEMES", FALSE);
        */
        event.message_type = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
    }
    event.data_format = 8;
    gdk_event_send_clientmessage_toall((GdkEvent *)&event);
#endif
}

The _GTK_READ_RCFILES event is what evidently causes a theme update for all programs in GTK+ 2, but GTK+ 3 programs appear insensitive to it.

The _GTK_READ_RCFILES approach was also recommended here (in Python).

What would be an equivalent in GTK+ 3 and later?

Inductiveload
  • 6,094
  • 4
  • 29
  • 55
  • You should be running `gsd-xsettings` and theme changes via XSettings should just propagate automatically. – TingPing Jul 19 '17 at 04:54
  • Does that only work with GNOME Shell? I'm using Arch + i3, `gnome-settings-daemon` isn't normally installed, and when I did install it, `gnome-tweak-tool` complains of "Shell not installed or running" and `gsettings set org.gnome.desktop.interface gtk-theme ` doesn't seem to do anything either. – Inductiveload Jul 23 '17 at 16:26
  • It should work without gnome but I've not used it in that context personally. – TingPing Jul 24 '17 at 21:55

0 Answers0