bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Maximiliano Sandoval
Subject: bug#53458: [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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]