Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Standalone tool using private Apple framework to toggle display grayscale mode
#include <stdio.h>
// Compile with cc -o gray gray.c -framework UniversalAccess -F /System/Library/PrivateFrameworks
extern void UAGrayscaleSetEnabled(int isEnabled);
extern int UAGrayscaleIsEnabled();
int main() {
UAGrayscaleSetEnabled(!UAGrayscaleIsEnabled());
}
@Jean-Daniel

This comment has been minimized.

Copy link

commented Apr 10, 2019

Want to avoid private framework ? You can do this using private API from public framework (I'm using it since 10.3 at least):

#include <CoreGraphics/CoreGraphics.h>

extern Boolean CGDisplayUsesForceToGray(void);
extern void CGDisplayForceToGray(Boolean gray);

int main() {
  CGDisplayForceToGray(!CGDisplayUsesForceToGray());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.