system-preferences.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { deprecate } from 'electron/main';
  2. const { systemPreferences } = process._linkedBinding('electron_browser_system_preferences');
  3. if ('getAppLevelAppearance' in systemPreferences) {
  4. const nativeALAGetter = systemPreferences.getAppLevelAppearance;
  5. const nativeALASetter = systemPreferences.setAppLevelAppearance;
  6. Object.defineProperty(systemPreferences, 'appLevelAppearance', {
  7. get: () => nativeALAGetter.call(systemPreferences),
  8. set: (appearance) => nativeALASetter.call(systemPreferences, appearance)
  9. });
  10. }
  11. if ('getEffectiveAppearance' in systemPreferences) {
  12. const nativeEAGetter = systemPreferences.getEffectiveAppearance;
  13. Object.defineProperty(systemPreferences, 'effectiveAppearance', {
  14. get: () => nativeEAGetter.call(systemPreferences)
  15. });
  16. }
  17. systemPreferences.isDarkMode = deprecate.moveAPI(
  18. systemPreferences.isDarkMode,
  19. 'systemPreferences.isDarkMode()',
  20. 'nativeTheme.shouldUseDarkColors'
  21. );
  22. systemPreferences.isInvertedColorScheme = deprecate.moveAPI(
  23. systemPreferences.isInvertedColorScheme,
  24. 'systemPreferences.isInvertedColorScheme()',
  25. 'nativeTheme.shouldUseInvertedColorScheme'
  26. );
  27. systemPreferences.isHighContrastColorScheme = deprecate.moveAPI(
  28. systemPreferences.isHighContrastColorScheme,
  29. 'systemPreferences.isHighContrastColorScheme()',
  30. 'nativeTheme.shouldUseHighContrastColors'
  31. );
  32. export default systemPreferences;