Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command to change all system keyboard shortcuts #327

Open
2 tasks done
VoxDai opened this issue Dec 9, 2023 · 0 comments
Open
2 tasks done

Command to change all system keyboard shortcuts #327

VoxDai opened this issue Dec 9, 2023 · 0 comments
Labels
discussion Discuss about macOS automation

Comments

@VoxDai
Copy link

VoxDai commented Dec 9, 2023

  • I made sure this feature is not in the commands list
  • I searched and didn't find this feature request in the listed issues

Hi, I recently find out that there is a prefs file which manages all the system keyboard shortcuts. It's named com.apple.symbolichotkeys.plist and it's in ~/Library/Preferences/. I've figured out how does this prefs file work, but I don't know the defaults command for it. I will explain how does this file work, and hopefully someone can find the command.


Open this file with Xcode, and It would look like this:

Screenshot 2023-12-09 at 00 24 01

There are a bunch of key, and each key is an ID number of a shortcut. For example, the key of Command + Option + Space is 65.


Screenshot 2023-12-09 at 00 39 05
  • enabled is a bool value controls whether this shortcuts is enabled.
  • parameters is an array controls which keys are assigned to this shortcut.
    • Item 0 is the ASCII code of the character. For example, the ASCII code of Space is 32, so the Item 0 is set to 32. For non-ASCII characters, Item 0 is set to 65535.
    • Item 1 is the keyboard key code for the character. The key code for Space key is 49, so Item 1 is set to 49. A few key codes are listing here and Key Codes is helpful to find all the key codes.
    • Item 2 is the sum of the Control, Command, Shift and Option keys. These are bits 17-20 in binary: Shift is bit 17(=131072), Control is bit 18(=262144), Option is bit 19(=524288), and Command is bit 20(=1048576). For Command + Option + Space, it means 1048576 + 524288 = 1572864, so Item 2 is set to 1572864.

Restarting the Mac is necessary to take into effect the changes.
For more info, see:
krypted.com
web.archive.org

@VoxDai VoxDai added the discussion Discuss about macOS automation label Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss about macOS automation
Projects
None yet
Development

No branches or pull requests

1 participant