Subject: bug#53458: [Request, Linux] Follow system dark mode user preference

From: Rudolf Schlatte <[email-masked]>
Date: Sun, 23 Jan 2022 12:02:44 +0100

Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <[email-masked]> writes:

> Maximiliano Sandoval <[email-masked]> writes:
>
>> Recently a new setting was added to xdg-desktop-portal to declare the user
>> preference for a dark mode. This setting is DE-agnostic¹ and it is sandbox
>> friendly. The dark mode setting will be officially supported in GNOME 42,
>> elementary OS already supports it, and there is a merge request for KDE that
>> will most likely included its next release.
>>
>> How to implement
>
> Isn't the window manager and GTK+ responsible for this, and not the
> applications themselves?

The OS changes the title bar color etc., but such a change would let
Emacs adapt frame contents, for example by changing the active theme.
To give a concrete example, I have the snippet below in my init file,
evaluated when I'm running Yamamoto-san's Mac port:

  (add-hook 'mac-effective-appearance-change-hook
            #'(lambda () (pcase (plist-get (mac-application-state) :appearance)
                           ("NSAppearanceNameDarkAqua" (modus-themes-load-vivendi))
                           ("NSAppearanceNameAqua" (modus-themes-load-operandi)))))