How to enable keyboard shortcut preference after modifying it through `defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys`

defaultskeyboardshortcut

I modify keyboard shortcut by defaults command.

For example,

# Disable "Search word in terminal man page index"
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 124 "<dict><key>enabled</key><false/><key>value</key><dict><key>parameters</key><array><integer>65535</integer><integer>26</integer><integer>262144</integer></array><key>type</key><string>standard</string></dict></dict>"

# Change "Move focus to next window" shortcut to Alt + Tab
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 27 "<dict><key>enabled</key><true/><key>value</key><dict><key>parameters</key><array><integer>65535</integer><integer>48</integer><integer>524288</integer></array><key>type</key><string>standard</string></dict></dict>"

How can I enable to work them without restart OS?

I expect there are some Input Service and need to restart it.

ex. killall SomeInputService

Best Answer

On macos Big Sur 11.2.1 I have been able to resolve this problem. This solution applies to com.apple.symbolichotkeys plist for OS wide shortcuts as well as trackpad related plists.

After running the default write ... commands, run the following command.

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

From my experience, it will read the plists and force them to take effect.

You may need to ensure the System Preferences app is not running before you run the command.

Some log output will be available if you run this before:

defaults write com.apple.activatesettings log true

However there is no output about parsing the com.apple.symbolichotkeys plist although it seems to read that plist.