Applying changes instantaneously

Created On:

macOS ships with a defaults utility that allows scripting of various system and application preferences. Common tweaks include adjusting key repeat rates, controlling scroll direction and more. It can be easier to run a command that hunt through various preference panes and allows you to version control your preferences.

I’ve found that there is an interesting quirk when adjusting however. Other sets of preferences typically apply immediately or right after you restart Finder. However changes to don’t appear to apply instantaneously. For example, running:

defaults write AppleSymbolicHotKeys -dict-add 64 "

Disables the default ⌘-<space> binding that ships with macOS, which by default opens up Spotlight1. It’s equivalent of opening up System Preferences > Keyboard > Shortcuts > Spotlight and adjusting the keyboard settings there.

However running the defaults command does not appear to take effect right away. If another application tries to bind to ⌘-<space> it will get an error. Further, the System Preferences UI is not changed until you restart your computer.

To get around this oddity, we can use a private utility called activateSettings that ships with macOS. After adjusting with the defaults command simply run:

/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u

Disassembly of this binary shows that it will read all of the values in and bind all of those shortcuts, forcing them to take effect immediately. This allows anyone to adjust those shortcuts via defaults without restarting.

  1. More magic numbers and their functionality can be found here↩︎