unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Maximiliano Sandoval via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 53458@debbugs.gnu.org
Subject: bug#53458: [Request, Linux] Follow system dark mode user preference
Date: Sat, 22 Jan 2022 22:14:16 +0000	[thread overview]
Message-ID: <3iRhN5EFJnIdFLuFt_CnYryIAZSjHpoq96ZkkxYkI1DJS4cNYRyGd18E92AH1lTjuEY75njusiICZbdF_AD0brAkLZ_9o9Gk435hsZbXiho=@protonmail.com> (raw)

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





             reply	other threads:[~2022-01-22 22:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-22 22:14 Maximiliano Sandoval via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-01-23  2:04 ` bug#53458: [Request, Linux] Follow system dark mode user preference 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='3iRhN5EFJnIdFLuFt_CnYryIAZSjHpoq96ZkkxYkI1DJS4cNYRyGd18E92AH1lTjuEY75njusiICZbdF_AD0brAkLZ_9o9Gk435hsZbXiho=@protonmail.com' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=53458@debbugs.gnu.org \
    --cc=msandova@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).