Changing Universal Access preferences


Hi there,

I would like to change the increaseContrast option within a script. I use this shell command:

defaults write increaseContrast -bool true

On Mojave I don’t have the permissions anymore and so I’ve to add sudo or do shell script with administrator privileges.

The problem is, that unlike using the checkbox in the system preferences, running apps seem not to be informed about this changed preference. Is there a way to tell it to them so they change their appearance?

Is it possible with ASObjC? I’ve found NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification in the docs, but I don’t know how to use it.


(Shane Stanley) #2

I don’t like your chances, but you could try this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

set theNotif to current application's NSNotification's notificationWithName:(current application's NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) object:(missing value)
current application's NSDistributedNotificationCenter's defaultCenter()'s postNotification:theNotif

(Shane Stanley) #3

No, that’s wrong. That notification can only be sent by a special function, and you need to specify the target. I fear you’re out of luck.


(CK) #4

As there seems to be no other way, have you simply considered scripting System Preferences and System Events to do this ? I normally abhor UI scripting, but System Preferences is the one exception for which it lends itself very cleanly to.