How to Adjust Screen Brightness on Mac from Command Line

Aug 14, 2019 - 2 Comments

Terminal in MacOS X

Want to change the screen brightness on Mac from the command line? You can use the Terminal to adjust screen brightness to be brighter or dimmer with a few different methods, as we’ll demonstrate here.

First we’ll show you a handy way to increase or decrease Mac screen brightness using osascript at the command line, and we’ll also show you a handy third party command line tool to change display brightness from the Mac Terminal as well.

How to Increase Mac Screen Brightness from Command Line with AppleScript

Executing the following Apple Script at the Terminal of MacOS will increase the screen brightness by one notch, like pressing the brightness up button on a Mac keyboard:

osascript -e 'tell application "System Events"' -e 'key code 145' -e ' end tell'

Run that command several times to increase the brightness more, you can use the up arrow and return trick to run it again, or you can use the !! to re-run last executed command tip as well.

How to Decrease Mac Screen Brightness from Command Line with AppleScript

Executing the following AppleScript at the command line will dim the screen brightness by one notch, like pressing the brightness down key once on a Mac keyboard:

osascript -e 'tell application "System Events"' -e 'key code 144' -e ' end tell'

Therefore you can repeat that command to lower the brightness more if needed. You can also use the ‘run last command’ !! trick to effectively dim the setting another notch.

How to Change Mac Screen Brightness via Terminal with ‘brightness’

The ‘brightness’ tool is easy to use as long as you have Homebrew installed on the Mac, so assuming that’s the case let’s install the ‘brightness’ tool with the following command:

brew install brightness

After ‘brightness’ has installed, you can use it as follows:

To turn Mac screen brightness to 100% brightest setting:

brightness 1

To turn Mac display brightness to halfway point:

brightness 0.5

To dim Mac screen brightness to 25% dim setting:

brightness 0.25

You can view the ‘brightness’ source on GitHub if you are interested in how it works or want to review it.

If you know of another way of adjusting the brightness of a Mac display from the command line, let us know in the comments below.

.

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks

2 Comments

» Comments RSS Feed

  1. Axel says:

    Thank you for this command line. It does change my MB brightness but not the one of my external Apple Cinema Display – can you provide me pls with the command for this one?

  2. gospeed says:

    Hey bro,

    At least on my Mac….

    “key code 144” = brigthness up
    “key code 145” = brightness down

    MacPro 2012 (one of the best mac’s ever made:)

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site