OSX: Programmatically reassign Caps Lock functionality (as set via System Preferences)?

My question relates to the System Preferences parameter, which allows you to reassign Caps Lock , for example. Ctrl .

^ Is it possible to programmatically change this parameter?

First of all, I would be interested to achieve this through defaults or some kind of shell trick; second time through AppleScript (yuck).

I know that maybe I can achieve this using third-party tools like KeyRemap4MacBook, but this is a last resort. But I would prefer, if possible, a third-party solution.

My use case:

Using the Maestro keyboard and its nice macro triggers, I'm looking for the ability to automatically reassign Caps Lock -> Ctrl in applications like MacVim, and switch them back to regular Caps Lock when exiting affected applications.

+4
source share
1 answer

You can switch using AppleScript. This will be a simple automation method that will basically do the same switch in System Preferences automatically for you.

You can add the created AppleScript transition to the MacVim Scripts toolbar icon. Thus, while inside the application, you can switch it on and off, leaving it.

Is this what you are looking for? If you still need it, I will develop AppleScript for you and put it here a little.

0
source

Source: https://habr.com/ru/post/1391889/


All Articles