Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tilagav488

macrumors newbie
Original poster
Feb 28, 2024
1
0
Hi everyone,

I'm looking to adjust the intensity of color filters on my Mac more precisely than what's offered in System Preferences (Accessibility->Display->Color Filters near the bottom), preferably using the Terminal or Shortcuts app. I aim to automate or quickly change settings for different scenarios.

Has anyone managed to do this or has any scripts, Terminal commands, shortcuts, or automator to share?

Any guidance or tips would be greatly appreciated!

Thanks!
 
It's probably possible to do via applescript. If you want to do programatically you'll probably need to reverse engineer the underlying private api hit (e.g. display settings uses monitorpanel uses monitorpanel framework).
 
I do not have a solution but perhaps the following is useful nevertheless:
With the help of https://indiestack.com/2019/04/toggle-system-grayscale-mode/ I know you can toggle 'Greyscale' with this AppleScript using Python:
AppleScript:
set toggleGrayScript to "python -c 'from ctypes import cdll
lib = cdll.LoadLibrary(\"/System/Library/PrivateFrameworks/UniversalAccess.framework/UniversalAccess\")
lib.UAGrayscaleSetEnabled(lib.UAGrayscaleIsEnabled() == 0)
'"
do shell script toggleGrayScript
Newer systems (macOS 12.4+) come with Python 3 instead of 2 and therefore have to execute python3 -c
I used the same method to toggle 'Natural Scrolling' of a mouse / trackpad.

Back to the original question: With Xcode tools installed, you can execute the following to look for a.e. 'DisplayFilter' in the 'UniversalAccessPref.prefPane':
Code:
cd /System/Library/PreferencePanes/UniversalAccessPref.prefPane/Contents/MacOS/
nm UniversalAccessPref | grep DisplayFilter
Which reveals some interesting properties:
Code:
U _MADisplayFilterPrefGetBlueColorCorrectionIntensity
U _MADisplayFilterPrefGetCategoryEnabled
U _MADisplayFilterPrefGetGreenColorCorrectionIntensity
U _MADisplayFilterPrefGetRedColorCorrectionIntensity
U _MADisplayFilterPrefGetSingleColorHue
U _MADisplayFilterPrefGetSingleColorIntensity
U _MADisplayFilterPrefGetType
U _MADisplayFilterPrefSetBlueColorCorrectionIntensity
U _MADisplayFilterPrefSetCategoryEnabled
U _MADisplayFilterPrefSetGreenColorCorrectionIntensity
U _MADisplayFilterPrefSetRedColorCorrectionIntensity
U _MADisplayFilterPrefSetSingleColorHue
U _MADisplayFilterPrefSetSingleColorIntensity
U _MADisplayFilterPrefSetType

'MA' likely points to the 'MediaAccessibility.framework'.
So in an Applescript, I used this in an attempt to read the 'Color Intensity'
AppleScript:
set getColorFilterIntensity to "python -c 'from ctypes import cdll
lib = cdll.LoadLibrary(\"/System/Library/Frameworks/MediaAccessibility.framework/MediaAccessibility\")
print(lib.MADisplayFilterPrefGetSingleColorIntensity())
'"
do shell script getColorFilterIntensity
But the output varies everytime the script is executed. I have no experience or idea how to continue.
 
Last edited:
Nice finding. Probably experimenting from C directly is easier than doing it via pyObjC.

You'd probably want to look at the disassembly of the above, to check what the return type is. Also I think "MADisplayFilterPrefSetType" is probably needed first, I'm assuming it takes an enum value.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.