Apple - How can I dim the screen from Terminal?
You can install this command line tool from github.com/nriley/brightness. The install is pretty easy if you have homebrew:
brew install brightness
And usage is straightforward:
- Set 100% brightness:
brightness 1
- Set 50% brightness:
brightness 0.5
Unfortunately it doesn't work for external monitors. See Does Apple support DDC/CI for 3rd party displays via Apple's Thunderbolt to DVI adapter for background on why.
You can do it via an Applescript and run it as such:
Dimmer:
tell application "System Events"
key code 144
end tell
Brighter:
tell application "System Events"
key code 145
end tell
You can save these as .script files and then run them from the CLI like this:
osascript ~/Path/to/File
You may refer to this.
You can also do it this way, but that requires more setup.
I've created a node module for this that supports setting the brightness using the CLI. See https://github.com/kevva/brightness-cli.
npm install --global brightness-cli
And then simply just run brightness
from your command line.