grayscale 0.0.1

Enable or disable macOS grayscale display mode
docs.rs failed to build grayscale-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

grayscale

A tiny macOS command-line tool to enable, disable, or toggle system-wide grayscale mode.

Installation

From source

cargo install --path .

Build manually

git clone https://github.com/eugenehp/grayscale.git
cd grayscale
cargo build --release
cp target/release/grayscale /usr/local/bin/

Usage

grayscale on        # enable grayscale
grayscale off       # disable grayscale
grayscale toggle    # toggle the current state
grayscale status    # print "on" or "off" to stdout

status prints to stdout so it can be used in scripts:

if [ "$(grayscale status)" = "on" ]; then
    echo "display is grayscale"
fi

How it works

The tool calls UAGrayscaleSetEnabled and UAGrayscaleIsEnabled from Apple's private UniversalAccess.framework, loaded at runtime via dlopen. No Objective-C runtime or extra dependencies are needed.

Requirements

  • macOS (compile-time enforced)
  • The UniversalAccess private framework (ships with macOS)

Library usage

grayscale also exposes a library crate:

grayscale::enable();
grayscale::disable();

let on = grayscale::is_enabled();
let new_state = grayscale::toggle();

License

MIT