How to toggle with grayscale in Yosemite?

I prefer greyscale over inverting color when working in low light plus in general as its less strain on the eyes. But its too many clicks to toggle the settings. I am aware that to invert display color the shortcut is Cmd+Alt+Ctrl+8. And open Accessibility options with Cmd+Alt+F5, but there is no grayscale in the options. Right now, I open Accessibility via spotlight, then choose display & toggle the check box. I am wondering of there is any shortcut key for that? If not, is it possible to make a keyboard shortcut.


The following example AppleScript code will toggle the state of the "Use grayscale" checkbox in Accessibility under System Preferences in OS X Yosemite (tested under 10.10.4) regardless of what was last selected under Accessibility as it tells System Preferences to open directly to the location of the "Use grayscale" checkbox and toggle its state.

tell application "System Preferences"
    reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"
    tell application "System Events" to tell front window of application process "System Preferences"
        with timeout of 5 seconds
            repeat until (exists checkbox "Use grayscale")
                delay 0.1
            end repeat
            click checkbox "Use grayscale"
        end timeout
    end tell
    quit
end tell

The next issue is how you want to execute it. The problem surrounding setting it as a Service through Automator to use a Keyboard shortcut without the use of a third party utility is every application that receives the shortcut key combo will need to have permission to do so and that becomes a pain unless you only choose e.g. Finder instead of all applications. So without a third party utility I'd either save it as a script in the Users Script folder and then access it from the Script menu in the Apple menu bar or as an application.

The settings for the Script menu in the Apple menu bar are in the Script Editors Preferences. Then it's just two mouse clicks anytime you want to toggle the state of the "Use grayscale" checkbox. One to click the Scripts menu and another to click the script name.

As an application it can be placed in the Dock and then it's a single mouse click anytime you want to toggle the state of the "Use grayscale" checkbox.

In either of these two cases you'll have to give permission under Accessibility on the Privacy tab of Security & Privacy in System Preferences in order to run it successfully.


As a side note, if you use a program like FastScripts, you only need to use the example AppleScript code as a .scpt saved in Script Editor, not create an Automator service using the mentioned workaround in the comment and can assigned the keyboard shortcut in the Preferences for FastScripts.

Note that I am not affiliated with the developer of FastScripts, just a satisfied user.


I have found an old Apple Discussion about this and the user who answered the question has posted an AppleScript file that will turn on and off grayscale. I have modified the original code so it would work with OS X Yosemite.

Open "Script Editor" and, in a new document, paste the following:

tell application "System Preferences" to activate
delay 1

tell application "System Events"
tell process "System Preferences"
click the menu item "Accessibility" of the menu "View" of menu bar 1
delay 0.5
click the checkbox "Use grayscale" of window "Accessibility"
end tell
end tell
tell application "System Preferences" to quit

Click the hammer to compile it and then save but where it says "File Format" in the save dialog, choose "Application"

Before running this code make sure that "Display" in Accessibility has been selected like the image below. Once that has been done, you can quit System Preferences.

Make sure that before running this, "Display" is highlighted in Accessibility

On the first run of the app, it will crash and OS X will ask if you want to allow the app to control the computer using accessibility features. Allow access, quit the app and relaunch it.

Sometimes this will not work and will crash with an error message. If this happens, just relaunch it and it will work fine.

EDIT: This may help with making it a keyboard shortcut: Link


I used the script from @CreeperzEdge answer and it had a bit of delay on my computer. I've slightly changed that script to:

tell application "System Preferences" to reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"
tell application "System Preferences"
    activate
    tell application "System Events" to tell process "System Preferences"
        click the checkbox "Use grayscale" of window "Accessibility"
    end tell
end tell

tell application "System Preferences" to quit

Somehow

tell application "System Preferences" to reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"

is faster than

tell application "System Preferences"
    activate
    reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"
end tell

I would be curious about others' experience.


I found that a 1-second delay was needed to get it to work for me.

tell application "System Preferences"
    activate
    reveal anchor "Seeing_Display" of pane "com.apple.preference.universalaccess"
    delay 1
    tell application "System Events" to tell process "System Preferences"
        click the checkbox "Use grayscale" of window "Accessibility"
    end tell
end tell
tell application "System Preferences" to quit

I have built an app to make this process easier. It allows you to toggle the grayscale display from the status bar. It's a wrapper around the AppleScript mentioned in the answers written using PyObjC. I have tested it to work on macOS Mojave.

You can download it from here. The source code is here.

Note: Due to Apple's restrictions, the app needs three kinds of permissions in order to work: a) allow opening an app from an unidentified developer b) allow access to System Events. c) accessibility permissions.