element-hq / element-desktop

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

Match system theme does not always update when the system theme changes (macOS at least) #881

Open adbjesus opened 4 years ago

adbjesus commented 4 years ago

Description

On the Element desktop app in macOS Catalina the theme is not getting updated from dark to light when the system theme changes (automatically or otherwise) despite the "match system theme" option being on. However, from light to dark the change seems to happen correctly.

Steps to reproduce

Version information

t3chguy commented 4 years ago

Yeah, the theme is only read during start-up

adbjesus commented 4 years ago

Is that really the case? Because then I would expect the step

  • Go back to macOS settings and set appearance to dark
    • Element updates the theme to dark correctly

to not work as well.

Regardless I would argue that changing Element's theme when the system theme changes is an expected behavior in macOS Catalina since the OS has an option to automatically change the theme between light and dark (when it's day or night respectively) and other common apps do just that.

Edit: From a quick look over the code in this repo and in matrix-react-sdk I only see the theme being set during start-up like you said. So I wonder why that first change works.

Edit 2: A bit more testing and I am not seeing a consistent behavior. Sometimes it keeps changing themes as I expected. But other times it only works for the first change like I initially described.

daenney commented 3 years ago

Per vector-im/element-web#16944, this also doesn't work as expected on Linux (Gnome 40 in my case). The light/dark theme matches the light/dark theme OS setting at launch, but doesn't follow any updates of the light/dark OS theme.

sam9032 commented 3 years ago

Yes, i can confirm that it doesn't work as expected in gnome. Would be amazing if element changes the theme as soon as the OS switches between light and dark. Sadly, most electron apps have this problem.

yajo commented 3 years ago

I use GNOME 40 with https://extensions.gnome.org/extension/2236/night-theme-switcher/ and it doesn't work even at launch. 🤔 Although it immediately switches the title bar to dark.

starcraft66 commented 2 years ago

I observe this problem on my macs as well as on windows using AutoDarkModeX. Element is the only app on these systems I have that claims to follow the system theme but doesn't.

sam9032 commented 2 years ago

Meanwhile I use schildichat to work around this problem, there is a cli command, which changes the theme. So the night-theme-switcher extension triggers this command as soon as it switches from dark to light or vice versa. I don't know if this is possible on mac or windows.

It is described in a schildichat release: https://github.com/SchildiChat/schildichat-desktop/releases/tag/v1.8.4-sc1

Linux users suffer from a Chromium bug which prevents the theme being updated if the system theme is being changed. There's now a workaround with cli options which allows to override the detected system theme even for a running profile through abusing the multi instance prevention mechanism. Let it switch to light mode: schildichat-desktop --system-theme-light-override --hidden Let it switch to dark mode: schildichat-desktop --system-theme-dark-override --hidden You have to do this for each profile seperately, just append the --profile option to above commands.

JMoVS commented 2 years ago

As a new user on MacOS - I can only confirm this issue and would love to see it fixed - the quick fix for me so far is simply restarting the app.

t3chguy commented 2 years ago

Cannot reproduce on Firefox, but can on Chrome (and thus Desktop app) on macOS The change event doesn't fire so this seems like a Chrome bug. You can test using window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", args => console.log("@@", ...args)); which never seems to fire.

https://user-images.githubusercontent.com/2403652/183841166-5ba88cf2-911d-41ad-a808-8404b11a0351.mov