Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nativeTheme not receiving updated event respecting Linux system preference change #25925

Closed
3 tasks done
davidwinter opened this issue Oct 13, 2020 · 11 comments
Closed
3 tasks done

Comments

@davidwinter
Copy link

davidwinter commented Oct 13, 2020

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 10.1.3 11.0.1
  • Operating System:
    • Ubuntu 20.04 x64

Expected Behavior

When switching "Window theme" preference between Light and Dark modes on Ubuntu, the updated event should be triggered for nativeTheme.

Actual Behavior

The updated event is never triggered when alternating between window themes.

To Reproduce

See: https://github.com/davidwinter/electron-native-theme/blob/master/main.js

$ git clone https://github.com/davidwinter/electron-native-theme.git
$ yarn
$ ./node_modules/.bin/electron main.js

Screenshots

image

@ckerr
Copy link
Member

ckerr commented Oct 19, 2020

I think this is fixed as a side-effect of #23479

@davidwinter
Copy link
Author

davidwinter commented Nov 18, 2020

This is still broken with 11.0.1 @ckerr

Example repo updated.

@shiftkey
Copy link
Contributor

I'm seeing similar behaviour on Ubuntu 20.04 with Electron 11.1.1 while working with GitHub Desktop's Linux fork. I can put together a better repro but the short version:

  • changing from Yaru-light to Yaru-dark does update the default chrome of the app
  • querying from the console for nativeTheme.shouldUseDarkColors shows the correct value
  • but the updated event on nativeTheme doesn't fire, so the app content itself is unable to switch from light to dark as the OS changes

This limits us being able to emulate the "Automatically switch theme to match system theme" behaviour that macOS and Windows now allow us to do in the app.

@julianfairfax
Copy link

Hopefully this can be resolved somehow. I use an extension to change my theme automatically depending on time of day, and Electron apps (most of my apps) use the system theme when launching, but as mentioned don't update it after the theme has been changed, and they require a relaunch.

@ffflorian
Copy link
Contributor

Also doesn't work with 11.4.1 and 12.0.1, but seems to be fixed with 13.0.0-beta.7. 🎉

@julianfairfax
Copy link

Also doesn't work with 11.4.1 and 12.0.1, but seems to be fixed with 13.0.0-beta.7. 🎉

Is there any indication of when version 13 will be released? And will the electron apps I use have to each be individually updated by their developer?

@ffflorian
Copy link
Contributor

@julian-fairfax

Is there any indication of when version 13 will be released?

Electron 13 stable release is scheduled for 2021-05-25.

And will the electron apps I use have to each be individually updated by their developer?

Yes.

@Nantris
Copy link
Contributor

Nantris commented Mar 24, 2021

Any hope for a backport on this fix, to at least 11.x?

@shiftkey's finding that the value is updated but 'updated' event is never triggered is interesting. That seems not to be the case for me on Mint 20.1 xfce.

For us the value of nativeTheme.shouldUseDarkColors seems to be defined at the first run of the main process and doesn't change after that. If we create new windows, we will still get the old value if we run something like this in devtools: window.matchMedia('(prefers-color-scheme: dark)')

@Nantris
Copy link
Contributor

Nantris commented Apr 1, 2021

Anybody on the team know what PR may have resolved the issue for @ffflorian and whether it might be backport-able?

@nornagon
Copy link
Member

nornagon commented Apr 1, 2021

Closing this as fixed, but feel free to continue discussing backports.

@aykevl
Copy link

aykevl commented Oct 11, 2022

Unfortunately, this doesn't appear to be working on KDE (current Arch Linux ARM / Asahi Linux, KDE Plasma 5.25.5). Most other applications do automatically update when the theme changes, including all tested KDE apps, Firefox, and Inkscape (GIMP and Chromium don't). The correct theme is applied on startup, but doesn't get updated when the system theme changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants