As I don't use GNOME, I cannot say specifically with regards to that, but under KDE, it's pretty straight forward and presumably this can be adapted to GNOME with very few changes:
(when (and IS-LINUX ;; this is doom specific
(featurep! :ui dbus)) ;; so is this
;; I should use a better name than `a`
(defun theme--handle-dbus-event (a setting values)
"Handler for FreeDesktop theme changes."
(when (string= setting "ColorScheme")
(let ((scheme (car values)))
(cond
((string-match-p "Dark" scheme)
(+theme-dark)) ;; my custom function that sets a dark theme
((string-match-p "Light" scheme)
(+theme-light)) ;; 1000 internet points to whoever guesses what this does
(t (message "I don't know how to handle scheme: %s" scheme))))))
(require 'dbus)
;; since this is all FreeDesktop stuff, this *might* work on GNOME without changes
(dbus-register-signal :session
"org.freedesktop.portal"
"/org/freedesktop/portal/desktop"
"org.freedesktop.impl.portal.Settings"
"SettingChanged"
#'theme--handle-dbus-event))