5

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?

2 Answers 2

2

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.

2
  • 1
    Can confirm on a brand new mbp 2021 silicon, that the above script works as described. Thank you!
    – Simon
    Feb 27, 2022 at 3:07
  • Thank you for providing an up to date answer :)
    – Tim
    Mar 16, 2022 at 20:46
6

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.

2
  • This is not working on a fresh install of macOS Monterey. "Set: Entry, "AppleSymbolicHotKeys:64:enabled", Does Not Exist". If you click on the UI checkbox, the system creates the Dict and the error disappears. This said the accepted answer is not helpful on fresh installs.
    – kilianc
    Nov 22, 2021 at 21:25
  • To not confuse users coming to this answer I reassigned the accepted answer to something working on current Mac models.
    – Tim
    Mar 16, 2022 at 20:48

You must log in to answer this question.

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