Modify System Keyboard Key-Repeat Rate?

So I'm trying to do a thing - have a macro that modifies the OS-level key repeat rate (found in the Keyboard system preference pane). Main reason is: I need a fast repeat rate in Pro Tools, but if I have any key repeat at all in World of Warcraft, the game's frame rate drops to a crawl (I have no idea why, but it does).

So I'd like to make a macro that sets the repeat rate to fast when I switch to Pro Tools, and sets it to slow when I switch to World of Warcraft. I've found some shell commands that let you change it:

defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)

But it seems that the 'defaults write' commands require a logout to actually take effect. Does anyone maybe have a trick to force-reload a defaults setting, so it updates immediately? I'd rather not have to keep my system preferences open and wave the Magic Wand of Cludge (ui scripting) at it every time.


Have you tried quitting and restarting a given app after setting the default?


It's a system-wide setting, I don't think restarting any particular app will change the setting for just that app - changing the setting in system preferences changes it system-wide for all apps, immediately.

Apps don't always respect system-wide settings unless and until they (the apps) are restarted or the system is restarted – it depends upon the app, the setting, and the method by which the setting is altered.

macOS has also adopted the habit of caching preferences, so direct alteration of preference files A) doesn't always work and B) may or may not work after a restart.

The defaults system is a different kettle of fish though. It's not uncommon for a new setting to be respected immediately or after an application is restarted.

We prefer settings that immediately update of course.