GNU bug report logs - #53458
[Request, Linux] Follow system dark mode user preference

Previous Next

Package: emacs;

Reported by: Maximiliano Sandoval <msandova <at> protonmail.com>

Date: Sat, 22 Jan 2022 22:15:01 UTC

Severity: wishlist

To reply to this bug, email your comments to 53458 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#53458; Package emacs. (Sat, 22 Jan 2022 22:15:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maximiliano Sandoval <msandova <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 22 Jan 2022 22:15:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maximiliano Sandoval <msandova <at> protonmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: [Request, Linux] Follow system dark mode user preference
Date: Sat, 22 Jan 2022 22:14:16 +0000
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: Emacs has to read via dbus the value of the setting and listen
for changes, then (if using a GtkHeaderBar) set the value of
GtkSetting:gtk-application-prefer-dark-theme so that the header bar/title bar of
emacs follows the preference. Ideally there could be `color-scheme` variable for
which the user can set values

 * prefer-light
 * prefer-dark
 * follow-system

and a `is-dark-mode` variable so that users can read its value and add hooks to
it.

Note that desktops environments might add dark/light mode schedulers based on
the time of the day, so it is important to be able to set hooks and listen to
the dbus for changes of the setting.

Relevant devel discussions:

- https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg01737.html
- https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00482.html

Relevant material:

- Freedesktop spec: https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Settings
- GNOME Dark mode initiative: https://gitlab.gnome.org/GNOME/Initiatives/-/issues/32
- C example (taken from the initiative): https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/uploads/b590f6ee98c68b652d95708f707ce927/hello.c

--
Maximiliano




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53458; Package emacs. (Sun, 23 Jan 2022 02:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 53458 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Maximiliano Sandoval <msandova <at> protonmail.com>
Cc: 53458 <at> debbugs.gnu.org
Subject: Re: bug#53458: [Request, Linux] Follow system dark mode user
 preference
Date: Sun, 23 Jan 2022 10:04:37 +0800
Maximiliano Sandoval <msandova <at> protonmail.com> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53458; Package emacs. (Sun, 23 Jan 2022 11:04:01 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Rudolf Schlatte <rudi <at> constantly.at>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#53458: [Request,
 Linux] Follow system dark mode user preference
Date: Sun, 23 Jan 2022 12:02:44 +0100
Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

> Maximiliano Sandoval <msandova <at> protonmail.com> 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))))) 







Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53458; Package emacs. (Sun, 23 Jan 2022 13:16:01 GMT) Full text and rfc822 format available.

Message #14 received at 53458 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Rudolf Schlatte <rudi <at> constantly.at>
Cc: 53458 <at> debbugs.gnu.org
Subject: Re: bug#53458: [Request, Linux] Follow system dark mode user
 preference
Date: Sun, 23 Jan 2022 21:14:50 +0800
Rudolf Schlatte <rudi <at> constantly.at> writes:

> 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.

For Emacs to change the GTK stylesheet when the system tells it to over
the XDG portal API doesn't mean it will necessarily be possible for Lisp
programs to obtain the name of the stylesheet being utilized, but I
think something like what Carbon Emacs has would be a good idea.

I'm not convinced that implementing the former is a good idea, since
changing the decoration style should be (and will probably be in the
future) handled by either GTK+ or the window manager, while these
standards come and go, but I am not opposed to the latter.

Patches welcome, thanks.




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Tue, 07 Jun 2022 21:49:02 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 69 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.