unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#53458: [Request, Linux] Follow system dark mode user preference
@ 2022-01-22 22:14 Maximiliano Sandoval via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-01-23  2:04 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Maximiliano Sandoval via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-22 22:14 UTC (permalink / raw)
  To: 53458

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#53458: [Request, Linux] Follow system dark mode user preference
  2022-01-22 22:14 bug#53458: [Request, Linux] Follow system dark mode user preference Maximiliano Sandoval via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-01-23  2:04 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-01-23 11:02   ` Rudolf Schlatte
  0 siblings, 1 reply; 4+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-23  2:04 UTC (permalink / raw)
  To: Maximiliano Sandoval; +Cc: 53458

Maximiliano Sandoval <msandova@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?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#53458: [Request, Linux] Follow system dark mode user preference
  2022-01-23  2:04 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-01-23 11:02   ` Rudolf Schlatte
  2022-01-23 13:14     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Rudolf Schlatte @ 2022-01-23 11:02 UTC (permalink / raw)
  To: 53458

Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs@gnu.org> writes:

> Maximiliano Sandoval <msandova@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))))) 








^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#53458: [Request, Linux] Follow system dark mode user preference
  2022-01-23 11:02   ` Rudolf Schlatte
@ 2022-01-23 13:14     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 4+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-23 13:14 UTC (permalink / raw)
  To: Rudolf Schlatte; +Cc: 53458

Rudolf Schlatte <rudi@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-23 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22 22:14 bug#53458: [Request, Linux] Follow system dark mode user preference Maximiliano Sandoval via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23  2:04 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23 11:02   ` Rudolf Schlatte
2022-01-23 13:14     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).