2

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

2 Answers 2

4

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.

0
1

On 12.1, I wasn't able to solve the issue with the accepted solution by itself, but by adding an additional step to ensure a defaults read on the plist prior to running activateSettings, things now correctly apply the new settings. I verified a few times that this additional step makes the difference and have a hunch that this step is lazily updating an in-memory cache of the plist file.

Example Usage:

# Disable Keyboard -> Shortcuts -> Mission Control -> Move left/right a space.
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:79:enabled false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:80:enabled false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:81:enabled false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:82:enabled false" ~/Library/Preferences/com.apple.symbolichotkeys.plist

# Ask the system to read the hotkey plist file and ignore the output. Likely updates an in-memory cache with the new plist values.
defaults read com.apple.symbolichotkeys.plist > /dev/null

# Run reactivateSettings to apply the updated settings.
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .