2020-07-13 16:58:49 +00:00
|
|
|
import { deprecate } from 'electron/main';
|
2020-07-28 18:03:30 +00:00
|
|
|
const { systemPreferences } = process._linkedBinding('electron_browser_system_preferences');
|
2019-08-14 20:42:55 +00:00
|
|
|
|
2020-03-18 01:06:52 +00:00
|
|
|
if ('getAppLevelAppearance' in systemPreferences) {
|
2020-03-20 20:28:31 +00:00
|
|
|
const nativeALAGetter = systemPreferences.getAppLevelAppearance;
|
|
|
|
const nativeALASetter = systemPreferences.setAppLevelAppearance;
|
2020-07-28 18:03:30 +00:00
|
|
|
Object.defineProperty(systemPreferences, 'appLevelAppearance', {
|
2020-03-18 01:06:52 +00:00
|
|
|
get: () => nativeALAGetter.call(systemPreferences),
|
|
|
|
set: (appearance) => nativeALASetter.call(systemPreferences, appearance)
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|
2019-08-14 20:42:55 +00:00
|
|
|
}
|
|
|
|
|
2020-03-18 01:06:52 +00:00
|
|
|
if ('getEffectiveAppearance' in systemPreferences) {
|
2020-03-20 20:28:31 +00:00
|
|
|
const nativeEAGetter = systemPreferences.getAppLevelAppearance;
|
2020-07-28 18:03:30 +00:00
|
|
|
Object.defineProperty(systemPreferences, 'effectiveAppearance', {
|
2020-03-18 01:06:52 +00:00
|
|
|
get: () => nativeEAGetter.call(systemPreferences)
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|
2019-08-14 20:42:55 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 18:03:30 +00:00
|
|
|
systemPreferences.isDarkMode = deprecate.moveAPI(
|
|
|
|
systemPreferences.isDarkMode,
|
2019-08-14 20:42:55 +00:00
|
|
|
'systemPreferences.isDarkMode()',
|
|
|
|
'nativeTheme.shouldUseDarkColors'
|
2020-03-20 20:28:31 +00:00
|
|
|
);
|
2020-07-28 18:03:30 +00:00
|
|
|
systemPreferences.isInvertedColorScheme = deprecate.moveAPI(
|
|
|
|
systemPreferences.isInvertedColorScheme,
|
2019-08-14 20:42:55 +00:00
|
|
|
'systemPreferences.isInvertedColorScheme()',
|
|
|
|
'nativeTheme.shouldUseInvertedColorScheme'
|
2020-03-20 20:28:31 +00:00
|
|
|
);
|
2020-07-28 18:03:30 +00:00
|
|
|
systemPreferences.isHighContrastColorScheme = deprecate.moveAPI(
|
|
|
|
systemPreferences.isHighContrastColorScheme,
|
2019-08-14 20:42:55 +00:00
|
|
|
'systemPreferences.isHighContrastColorScheme()',
|
|
|
|
'nativeTheme.shouldUseHighContrastColors'
|
2020-03-20 20:28:31 +00:00
|
|
|
);
|
2019-08-14 20:42:55 +00:00
|
|
|
|
2020-07-28 18:03:30 +00:00
|
|
|
export default systemPreferences;
|