Skip to content

Instantly share code, notes, and snippets.

@danielpunkass
Created April 9, 2019 12:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpunkass/df0d72be11b8956f2ef4f4d52cce7a41 to your computer and use it in GitHub Desktop.
Save danielpunkass/df0d72be11b8956f2ef4f4d52cce7a41 to your computer and use it in GitHub Desktop.
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
Copy link

Jean-Daniel 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