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

[themes] autoDetectColorScheme not working on Linux #102795

Closed
mcnesium opened this issue Jul 17, 2020 · 11 comments
Closed

[themes] autoDetectColorScheme not working on Linux #102795

mcnesium opened this issue Jul 17, 2020 · 11 comments
Assignees
Labels
feature-request Request for new features or functionality themes Color theme issues verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@mcnesium
Copy link

mcnesium commented Jul 17, 2020

When switching dark/light color themes in the OS, the opposite theme is being set in vscode. It even mixes it up right at the start. Watch the screencast:

vscode

  • VSCode Version: 1.47.1 (VSCodium)
  • OS Version: Manjaro Linux 20.0.3

Steps to Reproduce:

  1. Set prefered dark and light color themes in settings.json, e.g.:

    "workbench.colorTheme": "Atom One Light",
    "workbench.preferredDarkColorTheme": "Atom One Dark",
    "workbench.preferredLightColorTheme": "Atom One Light",
    "window.autoDetectColorScheme": true

  2. switch to the other theme in OS

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

@usernamehw
Copy link
Contributor

Do you get the same result if you launch without --disable-extensions flag?

@NotWearingPants
Copy link
Contributor

NotWearingPants commented Jul 17, 2020

This actually makes sense if your default theme is configured to be a dark theme.
What needs to happen is for vscode to check whether the configured theme aligns with the OS setting or not,
and then swap themes to keep the equality or inequality consistent.
Currently it seems that vscode always switches to the inverse.

i.e. if the OS is configured to light mode and a dark theme is active in vscode,
and then you switch the OS to dark mode, vscode should switch to a light theme.

@aeschli
Copy link
Contributor

aeschli commented Sep 1, 2020

We rely on Electron/Chrome to notify the OS color scheme change with a media query event

That wasn't supported on Linux, and I also don't see it working on Ubuntu 20.04
color-scheme-switching

Can you open the dev tools and set a breakpoint at 'handlePreferredSchemeUpdated' in vs/workbench/services/themes/browser/workbenchThemeService and see if it is hit when updating the color scheme?

private async handlePreferredSchemeUpdated() {

@aeschli aeschli modified the milestones: August 2020, September 2020 Sep 1, 2020
@mcnesium
Copy link
Author

mcnesium commented Sep 2, 2020

Okay I didn't realize that. Looks like Chromium does not follow the color scheme at all. Firefox on the left, Chromium on the right:

chromium

I set up the break point and found out that it does get hit. But I couldn't figure out anything more than that.

@aeschli aeschli changed the title preferred Dark/Light Color Themes are mixed up [themes] autoDetectColorScheme not working on Linux Sep 3, 2020
@aeschli
Copy link
Contributor

aeschli commented Sep 3, 2020

Instead of using the media event, I'll switch to use the new electron API. I'll give this a try in September

@aeschli aeschli modified the milestones: September 2020, Backlog Oct 2, 2020
@aeschli
Copy link
Contributor

aeschli commented Oct 2, 2020

We still don't get an an event from Electron

@AndreasBackx
Copy link
Contributor

We still don't get an an event from Electron

@aeschli should we perhaps create an issue on the Electron issue tracker for this? I couldn't find an existing issue.

@aeschli
Copy link
Contributor

aeschli commented Mar 23, 2021

The Electron issue is electron/electron#25925.

@SpineEyE
Copy link

Seeing that this was fixed for electron 13 and the vscode main branch uses electron 13, will this work in the next vscode version?

@Iss-in
Copy link

Iss-in commented Aug 14, 2021

waiting for an update on this one

@aeschli
Copy link
Contributor

aeschli commented Aug 18, 2021

I just tested that automatic theme switching based on the OS scheme works in VS Code 1.59 on Ubuntu 21.04.

  • set "window.autoDetectColorScheme": true
  • switching the OS themes with change the VS Code theme according to workbench.preferredDarkColorTheme and workbench.preferredLightColorTheme

@aeschli aeschli closed this as completed Aug 18, 2021
@aeschli aeschli modified the milestones: Backlog, August 2021 Aug 18, 2021
@aeschli aeschli added the verification-needed Verification of issue is requested label Aug 24, 2021
@bpasero bpasero added the verified Verification succeeded label Aug 24, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality themes Color theme issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants