Tim*_*Tim 5 keyboard-shortcuts bash macos
如何在不使用系统偏好设置的情况下禁用键盘快捷键Cmd+ ?Space
我已经找到了这个,但它并没有真正的帮助,因为我既不知道密钥也不知道如何将其设置为禁用。
有人可以帮助我吗?
Spotlight 键盘快捷键存储在com.apple.symbolichotkeys.
要禁用它,请运行以下命令:
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist -c \
"Set AppleSymbolicHotKeys:64:enabled false"
Run Code Online (Sandbox Code Playgroud)
注销后生效。
要重新启用,请将 false 替换为 true。
接受的答案不适用于全新安装,因为在用户单击 UI 之前,Dict条目AppleSymbolicHotKeys:64不存在。
就我而言,我正在尝试PlistBuddy编写 macOS 设置脚本。要求是没有 UI 交互。
PlistBuddy -help我在输出中寻找解决方案
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
Run Code Online (Sandbox Code Playgroud)
这是我的解决方案:
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist -c \
"Add :AppleSymbolicHotKeys:64:enabled bool false"
Run Code Online (Sandbox Code Playgroud)
如果key已经存在,PlistBuddy会打印出如下错误:
Add: ":AppleSymbolicHotKeys:64:enabled" Entry Already Exists
Run Code Online (Sandbox Code Playgroud)
您必须先删除该条目:
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.symbolichotkeys.plist -c \
"Delete :AppleSymbolicHotKeys:64"
Run Code Online (Sandbox Code Playgroud)
我的完整脚本禁用了macOS Monterey中的"Show Spotlight search"和选项:"Show Finder search window"
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
Run Code Online (Sandbox Code Playgroud)
PS 更改需要完全重新启动操作系统,我还没有找到解决此问题的方法。