Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Perl 6 to toggle greyscale on macOS
#!/usr/bin/env perl6
# see <> for the background on this.
use v6;
use NativeCall;
sub UALib { "/System/Library/PrivateFrameworks/UniversalAccess.framework/UniversalAccess" }
sub UAGrayscaleIsEnabled returns int32 is native(&UALib) { * }
sub UAGrayscaleSetEnabled (int32 $status) is native(&UALib) { * }
UAGrayscaleSetEnabled(UAGrayscaleIsEnabled() == 0);
say UAGrayscaleIsEnabled() ?? "Grayscale now enabled" !! "Colors now enabled";

This comment has been minimized.

Copy link
Owner Author

commented Apr 15, 2019

Hi! I received a lot of help making this work from the Perl6 IRC chatroom, in particular from timotimo; and also from ugexe on GitHub.

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.