Skip to content

[themes] auto detect color scheme not working on Linux #91169

Closed

Description

  • VSCode Version: latest stable & also 1.43.0-insider
  • OS Version: Fedora 31, GNOME 3.34.4

Steps to Reproduce:

  1. Launch VScode, set window.autoDetectColorScheme to true
  2. Set dark/light Adwaita theme in GNOME
  3. Firefox 73 & Chromium 79 does react, VS Code doesn't.

Does this issue occur when all extensions are disabled?: Yes/No

VS Code insiders, fresh profile.

Version: 1.43.0-insider
Commit: e6a45f4242ebddb7aa9a229f85555e8a3bd987e2
Date: 2020-02-21T05:40:52.685Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 5.4.20-200.fc31.x86_64

I did some debugging, this is where the magic happens.

Unfortunately, window.matchMedia((prefers-color-scheme: light)).matches === true and window.matchMedia((prefers-color-scheme: dark)).matches === false regardless of my system theme.

This is maybe a Chromium bug since the same wrong values are returned in Chromium but the right values are returned in Firefox. On the other hand, Chromium does auto-switch its color theme.

Also there's a nativeTheme Electron API. What does that have to do with this?

Activity

  1. gombosg commented on Feb 21, 2020

    @gombosg
    Author

    I'm trying to figure out why since prefers-color-scheme is supposed to be OS and browser independent.
    It's probably this and especially this bug.
    Apparently someone tried to fix it but it didn't work out as expected.

  2. gombosg commented on Feb 21, 2020

    @gombosg
    Author

    I tested the nativeTheme API and it also returns the wrong (always light theme) value on Linux. 😿

  3. aeschli commented on Feb 25, 2020

    @aeschli
    Contributor

    Thanks for digging up the links. We will have to wait for Chromium to have the feature.
    In the meantime I can disable the feature for Linux or add a remark to the description, if that's any help.

  4. added
    themes
    debt
    on May 10, 2020
  5. Siilwyn commented on Oct 25, 2020

    @Siilwyn

    Tested with VSCode 1.50.1 on (Ubuntu) GNOME 3.26.3: It works when launching the editor but will not change when the theme is switched while the editor is open.

  6. ryanerwin commented on Oct 28, 2020

    @ryanerwin

    I'm getting the same behaviour as Selwyn (@Siilwyn)

    When I close VSCode, I can get the theme to toggle between light and dark, but since VSCode is basically always open this doesn't really help.

    Any suggestions on how to get this to work without closing VScode though? Even a command line workaround would be fine...

  7. aeschli commented on Oct 28, 2020

    @aeschli
    Contributor

    As mentioned, we're waiting for Electron/Chromium support to detect os color scheme changes. There's no workaround yet.

  8. changed the title [-]auto detect color scheme not working on Linux[/-] [+][themes] auto detect color scheme not working on Linux[/+] on Nov 6, 2020
  9. added
    feature-request
    on Nov 6, 2020
  10. added a commit that references this issue on Aug 27, 2021
  11. thebrownfox commented on Mar 21, 2022

    @thebrownfox

    Looks like it's been fixed. Works for me.
    Martin Aeschlimann (@aeschli) You can probably close this one.

  12. aeschli commented on Mar 22, 2022

    @aeschli
    Contributor

    Yes, I can also confirm that this works for me on Ubuntu 21.10

  13. filviu commented on Mar 22, 2022

    @filviu

    Doesn't work for me on Fedora 35 and KDE switching between Breeze and Breeze Dark has no effect. Turning window.autoDetectColorScheme to true imediately switches to the Light theme.

  14. thebrownfox commented on Mar 22, 2022

    @thebrownfox

    @silviuvulcan not sure if there's such thing in KDE, but theme and color scheme are two different things. Theme is just a theme and color scheme should trigger changes accross the system if it's implemented (like in vscode or by default in gtk apps).

    Found this switcher but not sure whether it will be helpful
    https://github.com/baduhai/Koi

    Works for me on Arch Linux with Gnome 41.3 and oss version that uses system electron.

  15. connor4312 commented on Mar 23, 2022

    @connor4312
    Member

    Verified on Ubuntu as well

  16. filviu commented on Mar 24, 2022

    @filviu

    KDE has (not sure since what version) a global Dark/Light switch that changes theme and color scheme together. Also switching plasma style between a dark, light or "follow color scheme" one has no effect.

    Due to either KDE not reporting it or vscode not reading it switching any of the above between light and dark has no effect in vscode. I think it's safe to assume this is fixed only for Gnome not Plasma.

  17. aeschli commented on Mar 24, 2022

    @aeschli
    Contributor

    VS Code relies on Electron here, so please file an issue about missing support for KDE Dark/Light at https://github.com/electron/electron/issues.
    You can use https://github.com/aeschli/electron-theme-test to test the Electron nativeTheme API.

  18. firefoxic commented on Apr 29, 2022

    @firefoxic

    I think it's safe to assume this is fixed only for Gnome not Plasma.

    In Gnome 42, with the addition of the system light/dark theme switcher, this also broke.

  19. locked and limited conversation to collaborators on May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debtfeature-requestthemesverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions