how is it possible to disable the keyboard shortcut Cmd+Space without using the System Preferences?
I've already found this but it hasn't been really helpful because I neither know the key nor how to set it to disabled.
Can somebody assist me?
how is it possible to disable the keyboard shortcut Cmd+Space without using the System Preferences?
I've already found this but it hasn't been really helpful because I neither know the key nor how to set it to disabled.
Can somebody assist me?
The accepted answer does not work on a brand new install because the Dict
entry at AppleSymbolicHotKeys:64
does not exist until the user clicks on the UI.
In my case, I am trying to use PlistBuddy
to write a macOS setup script. The requirement is no UI interactions.
I looked for solutions in the PlistBuddy -help
output
Command Format:
Help - Prints this information
Exit - Exits the program, changes are not saved to the file
Save - Saves the current changes to the file
Revert - Reloads the last saved version of the file
Clear [<Type>] - Clears out all existing entries, and creates root of Type
Print [<Entry>] - Prints value of Entry. Otherwise, prints file
Set <Entry> <Value> - Sets the value at Entry to Value
Add <Entry> <Type> [<Value>] - Adds Entry to the plist, with value Value
Copy <EntrySrc> <EntryDst> - Copies the EntrySrc property to EntryDst
Delete <Entry> - Deletes Entry from the plist
Merge <file.plist> [<Entry>] - Adds the contents of file.plist to Entry
Import <Entry> <file> - Creates or sets Entry the contents of file
Entry Format:
Entries consist of property key names delimited by colons. Array items
are specified by a zero-based integer index. Examples:
:CFBundleShortVersionString
:CFBundleDocumentTypes:2:CFBundleTypeExtensions
Types:
string
array
dict
bool
real
integer
date
data
Examples:
Set :CFBundleIdentifier com.apple.plistbuddy
Sets the CFBundleIdentifier property to com.apple.plistbuddy
Add :CFBundleGetInfoString string "App version 1.0.1"
Adds the CFBundleGetInfoString property to the plist
Add :CFBundleDocumentTypes: dict
Adds a new item of type dict to the CFBundleDocumentTypes array
Add :CFBundleDocumentTypes:0 dict
Adds the new item to the beginning of the array
Delete :CFBundleDocumentTypes:0 dict
Deletes the FIRST item in the array
Delete :CFBundleDocumentTypes
Deletes the ENTIRE CFBundleDocumentTypes array
This is my solution:
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist -c \
"Add :AppleSymbolicHotKeys:64:enabled bool false"
If the key already exists, PlistBuddy
will print out the following error:
Add: ":AppleSymbolicHotKeys:64:enabled" Entry Already Exists
You have to delete the entry first:
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist -c \
"Delete :AppleSymbolicHotKeys:64"
My full script disables both the "Show Spotlight search"
and "Show Finder search window"
options in macOS Monterey:
#!/bin/bash
set -e
# target output for AppleSymbolicHotKeys:64
#
# <key>64</key>
# <dict>
# <key>enabled</key>
# <false/>
# <key>value</key>
# <dict>
# <key>parameters</key>
# <array>
# <integer>65535</integer>
# <integer>49</integer>
# <integer>1048576</integer>
# </array>
# <key>type</key>
# <string>standard</string>
# </dict>
# </dict>
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist \
-c "Delete :AppleSymbolicHotKeys:64" \
-c "Add :AppleSymbolicHotKeys:64:enabled bool false" \
-c "Add :AppleSymbolicHotKeys:64:value:parameters array" \
-c "Add :AppleSymbolicHotKeys:64:value:parameters: integer 65535" \
-c "Add :AppleSymbolicHotKeys:64:value:parameters: integer 49" \
-c "Add :AppleSymbolicHotKeys:64:value:parameters: integer 1048576" \
-c "Add :AppleSymbolicHotKeys:64:type string standard"
# target output for AppleSymbolicHotKeys:65
#
# <key>65</key>
# <dict>
# <key>enabled</key>
# <false/>
# <key>value</key>
# <dict>
# <key>parameters</key>
# <array>
# <integer>65535</integer>
# <integer>49</integer>
# <integer>1572864</integer>
# </array>
# <key>type</key>
# <string>standard</string>
# </dict>
# </dict>
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist \
-c "Delete :AppleSymbolicHotKeys:65" \
-c "Add :AppleSymbolicHotKeys:65:enabled bool false" \
-c "Add :AppleSymbolicHotKeys:65:value:parameters array" \
-c "Add :AppleSymbolicHotKeys:65:value:parameters: integer 65535" \
-c "Add :AppleSymbolicHotKeys:65:value:parameters: integer 49" \
-c "Add :AppleSymbolicHotKeys:65:value:parameters: integer 1572864" \
-c "Add :AppleSymbolicHotKeys:65:type string standard"
P.S. Changes require a full OS restart, I haven't found a way around this yet.
The Spotlight keyboard shortcut is stored in com.apple.symbolichotkeys
.
To disable it, run the following:
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist -c \
"Set AppleSymbolicHotKeys:64:enabled false"
This takes effect after log out.
To re-enable, replace false with true.