Merge pull request #8084 from poiru/systempreferences-setuserdefault

Add systemPreferences.setUserDefault for macOS
This commit is contained in:
Kevin Sawicki 2016-11-29 14:07:35 -08:00 committed by GitHub
commit 2c8ab72269
7 changed files with 169 additions and 11 deletions

View file

@ -114,16 +114,30 @@ Same as `unsubscribeNotification`, but removes the subscriber from `NSNotificati
Get the value of `key` in system preferences.
This API reads from `NSUserDefaults` on macOS, some popular `key` and `type`s
are:
This API uses `NSUserDefaults` on macOS. Some popular `key` and `type`s are:
* `AppleInterfaceStyle: string`
* `AppleAquaColorVariant: integer`
* `AppleHighlightColor: string`
* `AppleShowScrollBars: string`
* `NSNavRecentPlaces: array`
* `NSPreferredWebServices: dictionary`
* `NSUserDictionaryReplacementItems: array`
* `AppleInterfaceStyle`: `string`
* `AppleAquaColorVariant`: `integer`
* `AppleHighlightColor`: `string`
* `AppleShowScrollBars`: `string`
* `NSNavRecentPlaces`: `array`
* `NSPreferredWebServices`: `dictionary`
* `NSUserDictionaryReplacementItems`: `array`
### `systemPreferences.setUserDefault(key, type, value)` _macOS_
* `key` String
* `type` String - See [`getUserDefault`][#systempreferencesgetuserdefaultkey-type-macos]
* `value` String
Set the value of `key` in system preferences.
Note that `type` should match actual type of `value`. An exception is thrown
if they don't.
This API uses `NSUserDefaults` on macOS. Some popular `key` and `type`s are:
* `ApplePressAndHoldEnabled`: `boolean`
### `systemPreferences.isAeroGlassEnabled()` _Windows_