Electron: Consider to leverage `nativeTheme.themeSource` to enforce light or dark mode in window
See original GitHub issueI’m always using Dark+ Theme at VSCode (regardless of macOS light/dark appearance), but when window.titleBarStyle
set to native
, title bar style is mismatching with VSCode theme (if system-wide appearance is light). looks like this:
Electron has require("electron").nativeTheme.themeSource
API and BrowserWindow#vibrancy
API that can overrides system appearance per app/window, so I injected require("electron").nativeTheme.themeSource = "dark"
to Visual Studio Code.app/Contents/Resources/app/out/main.js
(yeah, its unsupported, i know) and looks pretty great.
However, I think code injection is not supported, possibly corrupting the installed VS Code, and disabling it with every VS Code update.
so I’ll suggest new settings that overrides macOS appearance based on VSCode theme.
Note: I think this new settings may conflicts with window.autoDetectColorScheme
and window.autoDetectHighContrast
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:11 (11 by maintainers)
Top GitHub Comments
I tested this and it seems to work really well on macOS at least. Still, I wonder if this needs to be a separate setting that the user can control it and wether we should not do this automatically.
@aeschli do you have thoughts on this? I know you have added theming related code and settings that automatically switch the theme in VSCode between dark and light depending on the OS setting. Here we would introduce a setting for the user to “hard-code” the appearance of the application to be either dark or light. I would think this setting can only be application scoped and not per workspace though because we need to resolve this from the main side.
Demo:
I am worried that this is a somewhat breaking change for everyone that just runs with default settings and might be confusing for users. If macOS is running in light mode (default), it is probably weird that VSCode suddenly appears dark, both in the window title as well as context menus.
So I think either a new setting or an update to the existing setting is still needed.