Gtk
Settings
Wayland
GSettingsis the primary configuration storage for most GNOME programs and indeed used for retrieving the theme name in GTK 3 underWayland.- Specifically, 
gdkdisplay-waylandusesgtk-themein theorg.gnome.desktop.interfaceschema. 
X11
- On 
X11, however, GTK uses theXSETTINGSprotocol, where a separate DE-specific daemon gets various settings from wherever it wants, and republishes them in a standard format using X11's selections mechanism. 
On startup, each client that should identify the settings window by calling
XGetSelectionOwner()for the_XSETTINGS_S[N]selection and select for notification on the settings window by callingXSelectInput()with a mask ofStructureNotifyMask|PropertyChangeMask.[...] The client can then proceed to read contents of the
_XSETTINGS_SETTINGSproperty from the settings window and interpret according to the information in the_XSETTINGS_SETTINGS Formatsection of this document
For e.g. in MATE, mate-settings-daemon is the XSETTINGS provider. It reads org.mate.interface from GSettings and re-publishes the value as Net/ThemeName via XSETTINGS, where GTK can finally retrieve it.
Usage of the XSETTINGS protocol makes the backend irrelevant – e.g. older GNOME and MATE versions used GConf, while Xfce uses XfConf, and there is a standalone xsettingsd which uses a text file. (On the other hand, as you can see the protocol is very specific to X11 and cannot be used within Wayland.)
- The 
xsettingsdpackage also comes with adump_xsettingstool which dumps data from whatever provider is currently running. 
Note that not all desktop environments run an XSETTINGS provider. For example, using LXDE's lxappearance simply edits the configuration files: ~/.gtkrc-2.0 for GTK 2, and ~/.config/gtk-3.0/settings.ini for GTK 3. These are always read, but used at the lowest priority – the GSettings or XSETTINGS specified parameters always win.
- GTK 3 supports 
$GTK_THEMEto temporarily override the theme. - In Wayland, GTK 3 reads theme name from 
GSettings, with configuration file as fallback. - In X11, GTK 2/3 retrieve theme name from an 
XSETTINGSdaemon, with configuration file as fallback. - GTK 1 does not support anything except file-based configuration (
gtkrc).