element-hq / element-desktop

A glossy Matrix collaboration client for desktop.
https://element.io
GNU Affero General Public License v3.0
1.15k stars 263 forks source link

Match theme does not respect system theme on GNOME #690

Closed kittykat closed 1 year ago

kittykat commented 3 years ago

Steps to reproduce

  1. Settings -> Appearance -> Theme -> :heavy_check_mark: Match system theme
  2. Switch system theme Observe the app theme not changing
  3. Disable "Match system theme" and chose the other theme from what is currently selected.
  4. Reselect "Match system theme" Observe the app theme not changing to match system theme

What happened?

"Match system theme" doesn't do anything (even with restarting browser in between).

What did you expect?

"Match system theme" to match system theme.

Operating system

Arch Linux

Browser information

Chromium Version 92.0.4515.131 (Official Build)

URL for webapp

develop.element.io

Homeserver

n/a

Have you submitted a rageshake?

No

kittykat commented 3 years ago

Could be a duplicate of vector-im/element-desktop#690 but mine is 100% reproducible for me.

mcnesium commented 3 years ago

I see element-web switching between light and dark theme according to the system theme works using app.element.io in Firefox/Linux (Gnome). It does not work in the desktop application though.

This has been a problem in vscode as well, but has been fixed upstream. Might be worth to take a look.

maurerle commented 2 years ago

This is not fixed on my device: Electron/13.5.2 Element version: 1.9.9 Olm version: 3.2.8

Debian 11, amd64, Gnome 3.38 Element-desktop installed from https://packages.riot.im/debian/ default main

Element updates the theme after a restart, but not while the app is opened

t3chguy commented 2 years ago

@kittykat which issue did you mean to link? This is 18801

kittykat commented 2 years ago

Sorry, not sure any more. Maybe vector-im/element-desktop#881 ?

arazilsongweaver commented 2 years ago

I have also encountered this issue with Gnome 42 on Fedora 36 (AMD64 Prerelease). I can not get Element to automatically transition to dark mode even after restarting the program.

OS: Fedora 36 Prerelease (AMD64) (as of 2022-03-24) Environment: Gnome 42.0 Package Source: Flathub Flatpak

saligari commented 2 years ago

There seems to be an issue with electron as well https://github.com/electron/electron/issues/33635 at least on Fedora 36/Gnome 42, or maybe it's been resolved. Also there's a standardized preference now: org.freedesktop.appearance color-scheme, although I don't know if that should be electron's job to support if it doesn't already. Mozilla supports it now: https://bugzilla.mozilla.org/show_bug.cgi?id=1734934

For what it's worth, for me as well, the electron apps I'm using aren't transitioning to dark mode, not even when restarting.

I see @EECvision working on https://github.com/vector-im/element-web/issues/19514, maybe this is relevant for you?

yajo commented 2 years ago

Element updates the theme after a restart, but not while the app is opened

This was true until Fedora 35 / GNOME 41.

In Fedora 36 / GNOME 42, it's not detecting system color mode anymore.

holocronweaver commented 2 years ago

In Ubuntu 22.04 / GNOME 42 desktop theme detection is broken in Element. The Element UI defaulted to light theme, though I have a dark desktop theme.

Doomsdayrs commented 1 year ago

As of Fedora 37, GNOME 43 this is still broken.

ghabit commented 1 year ago

Archlinux, GNOME 43 Element version: 1.11.10 Olm version: 3.2.12, doesn't work here too.

WhiteBlackGoose commented 1 year ago

Bumping this issue too

fjbaldon commented 1 year ago

Still broken on Gnome 43.3

Igetin commented 1 year ago

The upstream issue in Chromium has been fixed today, at long last. They have implemented a new DarkModeManagerLinux view that monitors the FreeDesktop settings portal, and falls back to GTK/QT theme monitoring for systems where the portal is not supported.

The fix is included Chromium 114, which is due for a stable (Chrome) release on the 30th of May. Electron follows Chromium in its releases, so the fix should land in Electron stable 25.0.0 on the same day.

t3chguy commented 1 year ago

Fixed by https://github.com/vector-im/element-desktop/issues/997

pchmykh commented 1 year ago

I have element-desktop 1.11.34-2 with element-web=1.11.34 electron25 libsecret dependencies and electron25 25.2.1-1, but element-desktop still doesn't change theme according to GNOME settings, how to fix it?

t3chguy commented 1 year ago

@pchmykh if thats a community package I suggest seeking help from its maintainers

q234rty commented 1 year ago

@t3chguy I can reproduce with a binary from https://packages.element.io/nightly/install/linux/glibc-x86-64/element-desktop-nightly.tar.gz , the issue was NOT fixed by just updating to electron25, I believe changes are needed in electron to adopt to the chromium changes.

t3chguy commented 1 year ago

Happy to re-open this but to reiterate, we use the prefers-color-scheme signal from the web. We don't do any OS-specific magics, those all happen upstream. So this issue won't get any fixes, so if its still not working for you an upstream issue is far more critical

Igetin commented 1 year ago

The upstream Electron issue was inadvertently closed as a duplicate a few months ago. On Chromium’s side, the Linux support for prefers-color-scheme was fixed in Chromium 114. This means that the prefers-color-scheme media query now works as expected on Chrome/Chromium on Linux distributions, and can now react to the change in both GTK/Qt themes and the XDG Settings portal preference.

However, despite Electron 25 shipping with Chromium 114, the prefers-color-scheme behaviour will not work as expected on newer Linux distirbutions that rely on the XDG Settings portal preference. This is because Electron 25 currently overrides Chromium’s behaviour, and they have an old Linux workaround in place. This workaround was never designed to work with newer distributions or the Settings portal.

I have explained this in more detail here, including the reproduction steps.


It seems that a fix for the problem is in the works on Electron’s side.

slagiewka commented 1 year ago

Good news! The Electron fix mentioned by @Igetin was merged and backported to 26.x branch (which Element currently uses). Now let's wait for the release 🙂

Doomsdayrs commented 1 year ago

The upstream Electron issue was inadvertently closed as a duplicate a few months ago. On Chromium’s side, the Linux support for prefers-color-scheme was fixed in Chromium 114. This means that the prefers-color-scheme media query now works as expected on Chrome/Chromium on Linux distributions, and can now react to the change in both GTK/Qt themes and the XDG Settings portal preference.

However, despite Electron 25 shipping with Chromium 114, the prefers-color-scheme behaviour will not work as expected on newer Linux distirbutions that rely on the XDG Settings portal preference. This is because Electron 25 currently overrides Chromium’s behaviour, and they have an old Linux workaround in place. This workaround was never designed to work with newer distributions or the Settings portal.

I have explained this in more detail here, including the reproduction steps.

It seems that a fix for the problem is in the works on Electron’s side.

Thank you for your efforts! Horrah!

slagiewka commented 1 year ago

The release https://github.com/electron/electron/releases/tag/v26.2.4

slagiewka commented 1 year ago

Element Desktop v1.11.45 now follows system theme as expected (on KDE + Flatpak at least).

So most likely fixed by #1254.

pchmykh commented 1 year ago

Not yet on arch, possible due to old electron release.

q234rty commented 1 year ago

Yeah, arch needs to update their electron packages, but that's purely downstream. Since the upstream release now works I guess this can be closed?

holocronweaver commented 1 year ago

Tested Element 1.11.45 via Flatpak on Ubuntu 22.04 (Gnome 42.9), can confirm 'Match system' theme setting works as expected! Hooray! :partying_face:

pchmykh commented 1 year ago

Tested Element 1.11.45 via Flatpak on Ubuntu 22.04 (Gnome 42.9), can confirm 'Match system' theme setting works as expected! Hooray! 🥳

Tried element from flathub, it works, but window title is always light. How do you solve this? Thanks.

holocronweaver commented 1 year ago

@pchmykh Did not experience that, what OS and desktop environment versions are you on?

pchmykh commented 1 year ago

@pchmykh Did not experience that, what OS and desktop environment versions are you on?

Tested at archlinux+GNOME and fedora39 in boxes vm.