#!/bin/sh
# Enable Keyboard -> Shortcuts -> Mission Control -> Move left/right a space.
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:79:enabled true" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:81:enabled true" ~/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
# Move to right Space
osascript -e 'tell application "System Events" to key code 123 using control down'
# 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:81: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
和rightspace.sh(相同的代码更改
key code 123
然后我测试了,请确保Apple脚本编辑器实用程序具有可访问性权限。然后,我禁用任务控制的关键捷径,然后进行了测试。它起作用的一个,我创建并应用了:
创建文件夹结构leftspace.app/contents/macos
将左Space.sh move到此文件夹
删除左Space.sh的扩展为左空间
to rightspace做同样的
最后,我将这两个应用程序添加到访问权限时,就像以前使用Apple Script Editor一样。