diff --git a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts index ca8c4e219..3bd5f13c8 100644 --- a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts +++ b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts @@ -139,7 +139,10 @@ export class SettingsService { this.preferenceService.get(FONT_SIZE_SETTING, 12), this.preferenceService.get( 'workbench.colorTheme', - 'arduino-theme' + window.matchMedia && + window.matchMedia('(prefers-color-scheme: dark)').matches + ? 'arduino-theme-dark' + : 'arduino-theme' ), this.preferenceService.get( AUTO_SAVE_SETTING, diff --git a/electron/build/patch/frontend/index.js b/electron/build/patch/frontend/index.js index 1d6a9ff32..8908654be 100644 --- a/electron/build/patch/frontend/index.js +++ b/electron/build/patch/frontend/index.js @@ -13,6 +13,9 @@ const { const { ApplicationProps, } = require('@theia/application-package/lib/application-props'); +const { + FrontendApplicationConfigProvider, +} = require('@theia/core/lib/browser/frontend-application-config-provider'); const lightTheme = 'arduino-theme'; const darkTheme = 'arduino-theme-dark'; @@ -21,13 +24,19 @@ const defaultTheme = ? darkTheme : lightTheme; +const originalGet = FrontendApplicationConfigProvider.get; +FrontendApplicationConfigProvider.get = function () { + const originalProps = originalGet.bind(FrontendApplicationConfigProvider)(); + return { ...originalProps, defaultTheme }; +}.bind(FrontendApplicationConfigProvider); + const arduinoDarkTheme = { id: 'arduino-theme-dark', type: 'dark', label: 'Dark (Arduino)', editorTheme: 'arduino-theme-dark', - activate() { }, - deactivate() { } + activate() {}, + deactivate() {}, }; const arduinoLightTheme = { @@ -35,8 +44,8 @@ const arduinoLightTheme = { type: 'light', label: 'Light (Arduino)', editorTheme: 'arduino-theme', - activate() { }, - deactivate() { } + activate() {}, + deactivate() {}, }; if (!window[ThemeServiceSymbol]) { @@ -49,7 +58,11 @@ if (!window[ThemeServiceSymbol]) { ); }, }); - themeService.register(...BuiltinThemeProvider.themes, arduinoDarkTheme, arduinoLightTheme); + themeService.register( + ...BuiltinThemeProvider.themes, + arduinoDarkTheme, + arduinoLightTheme + ); themeService.startupTheme(); themeService.setCurrentTheme(defaultTheme); window[ThemeServiceSymbol] = themeService;