Change Screen Brightness Mac Terminal
In this article
Yes, you can change your Mac's screen brightness directly from the Terminal using built-in commands or a small third-party utility. The most straightforward method is the brightness command (available via Homebrew) or the AppleScript approach that controls the display's brightness level without extra software.
Why Use Terminal for Brightness Control?
The Terminal gives you precise, scriptable control over your Mac's display brightness, which is useful for automating workflows, adjusting brightness in sync with time of day, or fixing issues when the brightness keys stop working. It also works on external displays that support DDC/CI, something the standard keyboard shortcuts often can't handle.
Built-in AppleScript Method
macOS includes a built-in AppleScript command that can set brightness without any extra tools. Open Terminal (Finder > Applications > Utilities > Terminal) and run:
osascript -e 'tell application "System Events" to set brightness of first display to 0.7'
This sets the brightness to 70% (0.0 = minimum, 1.0 = maximum). To get the current brightness, use:
osascript -e 'tell application "System Events" to get brightness of first display'
This method works on most Macs running macOS 10.12 or later, but it may not work on all external displays.
Using the brightness Command (Homebrew)
The most popular third-party tool is brightness, a small command-line utility available via Homebrew. Install Homebrew first (if you don't have it), then:
- Install the tool:
brew install brightness - Set brightness to 50%:
brightness 0.5 - Get current brightness:
brightness -v
This tool works with the built-in display and many external monitors, and it gives you instant feedback. It's particularly handy for scripting because it returns the current value when run without arguments.
Keyboard Shortcuts and Terminal Integration
If you prefer keyboard shortcuts but want them to work with Terminal, you can create custom shortcuts using macOS's built-in Shortcuts app or Automator. For example, you can create a Quick Action that runs the AppleScript above and assign it a keyboard shortcut in System Settings > Keyboard > Shortcuts. This gives you the convenience of keys with the flexibility of Terminal commands.
Common Problems and Fixes
- AppleScript returns an error: Make sure you're running the exact syntax. Some macOS versions require the display to be identified by name. Try
osascript -e 'tell application "System Events" to get brightness of display 1'. - External display not responding: The AppleScript method often only works on the built-in display. For external monitors, use the
brightnesstool or a dedicated utility like MonitorControl. - Brightness resets after reboot: If you want to set brightness at login, add the command to your login items or use a launchd plist.
- Permission issues: On newer macOS versions, you may need to grant Terminal permission to control System Events. Go to System Settings > Privacy & Security > Automation and enable the toggle for Terminal.
Scripting and Automation Ideas
Once you have the command working, you can create scripts to adjust brightness based on time of day, battery status, or ambient light (if you have a compatible sensor). For example, a cron job could lower brightness at 10 PM and raise it at 7 AM. Here's a simple shell script:
#!/bin/bash
# Set brightness to 0.3 at night, 0.8 during day
hour=$(date +%H)
if [ $hour -ge 22 ] || [ $hour -lt 7 ]; then
brightness 0.3
else
brightness 0.8
fi
Make it executable with chmod +x script.sh and run it via launchd or cron.
Alternatives to Terminal
If you're not comfortable with command line, you have other options: the standard brightness keys (F1/F2) on Mac keyboards, the Control Center slider (click the Control Center icon in the menu bar), or System Settings > Displays. For more advanced control, consider free apps like MonitorControl (open-source) or Lunar, which offer GUI sliders and automatic adjustments.
Frequently Asked Questions
Does the Terminal brightness command work on all Macs?
The AppleScript method works on most Macs running macOS 10.12 or later, but it may not work on external displays. The brightness tool from Homebrew works on a wider range of displays, including many external monitors.
How do I change brightness on an external monitor via Terminal?
Use the brightness tool (brew install brightness) and specify the display index if you have multiple. For example, brightness -d 2 0.5 sets the second display to 50%. Not all monitors support this; if it doesn't work, try MonitorControl.
Can I set brightness to a specific percentage?
Yes, both methods accept values from 0.0 (minimum) to 1.0 (maximum). For 50%, use 0.5. The brightness tool also accepts percentage directly: brightness 50%.
Why does my brightness reset after restart?
macOS resets brightness to a default value on reboot. To make it stick, run your brightness command at login using System Settings > Users & Groups > Login Items, or create a launchd agent.
Is there a way to adjust brightness without installing anything?
Yes, the AppleScript method requires no installation. Just open Terminal and run the osascript command. It's built into macOS.
Can I use Terminal to control brightness on an iMac or MacBook Pro with Touch Bar?
Yes, the same commands work on all Mac models. On MacBook Pro with Touch Bar, you can also add a brightness slider to the Control Strip, but Terminal commands work regardless.