Bug 143302 - Detect switches between dark and light GTK themes and automatically switch to the corresponding icon set when available
Summary: Detect switches between dark and light GTK themes and automatically switch to...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
7.0.5.2 release
Hardware: All Linux (All)
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsDevAdvice
Depends on:
Blocks: UI-Theming
  Show dependency treegraph
 
Reported: 2021-07-11 19:30 UTC by Jeff Fortin Tam
Modified: 2022-03-20 19:33 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Fortin Tam 2021-07-11 19:30:52 UTC
LibreOffice already has dark variants for two of its icon themes (Sifr and Breeze). I wish more of its icon themes (particularly Colibre and Sukapura) had dark variants, but this is not the issue today.

What I'm reporting today is that when the GTK theme changes, LibreOffice should detect if it's the normal version of a theme or if it's a dark variant, and then, if it has a compatible icon theme (that has a light and dark variant), switch the icon theme accordingly, automatically. Otherwise, things typically are unrecognizeable in dark mode.

This is particularly noticeable when you have systems where the OS (or a script, or an extension such as https://extensions.gnome.org/extension/2236/night-theme-switcher/). For what it's worth, Firefox does it and handles it beautifully, without needing user intervention or an app restart, when its theme is set to "system"; so it's possible, theoretically & technically speaking.
Comment 1 Heiko Tietze 2021-07-19 12:00:21 UTC
Yes, it's desirable. But can we detect whether the OS runs a dark or bright theme? Haven't looked into bug 127138 but it seems to be solved for Qt-based systems.
Comment 2 Jeff Fortin Tam 2021-07-19 14:32:01 UTC
> can we detect whether the OS runs a dark or bright theme?

I would think so, because Firefox manages to do it live without a restart. If you switch between light and dark GTK themes (or any GTK themes for that matter) and you're running the "system" toolbar style, Firefox will adapt everything as soon as you switch the GTK theme, and this also affects things like the "new tab" page. So I'm thinking, if Firefox can do it, surely there's a way for LibreOffice to do it too.
Comment 3 Jeff Fortin Tam 2022-03-20 19:33:39 UTC
Update (as further response to Heiko's previous question): this is now much more easily feasible, technically speaking, because there now is a standardized (i.e. FreeDesktop) way for LibreOffice to authoritatively know, without just trying to "guess" whether the current GTK theme is dark or not, what the user's intent is in terms of light/dark themes.

* Overview here: https://blogs.gnome.org/alexm/2021/10/04/dark-style-preference/
* Implementation tips here: https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/Dark-Style-Preference

With this knowledge of the user's intent and the system's state, LibreOffice would now be able to switch between the two in realtime with a clear standardized signal, and also it could now allow tighter integration, such as allowing the user to specify in the preferences if they want not just the UI/toolbars/icons to switch between light and dark when the system switches, but also whether they want to automatically use the "LibreOffice Dark" color scheme at the same time or if they want their documents' editing view rendering to remain black-on-white.

Many applications already support this with GNOME 42 and Elementary OS 6, even non-purely-GTK applications such as Firefox.