You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nativeTheme not receiving updated event respecting Linux system preference change #25925
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.
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.
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)')
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.
Reacted by Nho Quy Dinh, Dennis Værum, Luiz Henrique Laurini and Artem Nechunaev
Activity
ckerr commentedon Oct 19, 2020
I think this is fixed as a side-effect of #23479
davidwinter commentedon Nov 18, 2020
This is still broken with 11.0.1 @ckerr
Example repo updated.
shiftkey commentedon Mar 11, 2021
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:
nativeTheme.shouldUseDarkColorsshows the correct valueupdatedevent onnativeThemedoesn't fire, so the app content itself is unable to switch from light to dark as the OS changesThis 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 commentedon Mar 15, 2021
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 commentedon Mar 23, 2021
Also doesn't work with 11.4.1 and 12.0.1, but seems to be fixed with 13.0.0-beta.7. 🎉
julianfairfax commentedon Mar 23, 2021
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 commentedon Mar 23, 2021
@julian-fairfax
Electron 13 stable release is scheduled for 2021-05-25.
Yes.
Nantris commentedon 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.shouldUseDarkColorsseems to be defined at the first run of themainprocess 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 commentedon 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 commentedon Apr 1, 2021
Closing this as fixed, but feel free to continue discussing backports.
aykevl commentedon 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.