Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automatically adjust display brightness via Terminal / Pretty good solution

This hint is for all of you who experience any problem with the adjustment of the display brightness.

*Short version*
After a cold and/or warm start, it sometimes happens that the brightness was changed by the system itself to its dim power saver setting or maximum value and sometimes - what a big surprise - remains as it has been configured.
I had spotted plenty of articles about this phenomenon, but none of them yielded a solution. I then decided to solve this problem by going the pragmatically way and use some kind of software which dims the display to my preferred setting. And the winner is: brightness.
This tiny program works perfect and you will love its benefit by using it in terminal - yes, brightness is a command line utility. On top of this, brightness is able to control different displays, internal and external. The clou: beside using the precompiled binary you can also download the source code here, modify it to make the program fit your needs and then compile it using Xcode.

1. Installation
Download a precompiled version of the command line utility brightness here and extract the binary to your desired path (e.g. /usr/bin).

2. Usage
"brightness -l -v" dumps the current display attributes (-v for verbose mode) while "brightness 0.5" modifies the brightness of the main display to half of its max value and "brightness -m 1 1" let a second display become shiny. Just play little bit around.

3. Automatically launch
Simply create a .plist file and drop it, for example, in ~/Library/LaunchAgents. Or make use of an AppleScript or a Terminal Script to let it launch.

That's it. Comments are welcome.

*Long version*
It seems to be, that the adjustment of the display brightness of an iMac and MacBook/Pro (maybe also other models are affected) drives a life of its own. After a cold and/or warm start, it sometimes happens that the brightness was changed by the system itself to its dim power saver setting or maximum value and sometimes - what a big surprise - remains as it has been configured.
I had spotted plenty of articles about this phenomenon, but only found terms like "Did you already disabled the ambient light sensor", "Did you already reset the PRAM?", "Did you already reset the NVRAM?", "Did you already…BLAH". Far from it, all of these tips have one thing in common: none of them yielded a solution. As a last resort, I thought, it was a good idea to install 10.6 from the scratch just to find out that the above mentioned phenomenon occurs right after a few days of using OS X.
I then decided to solve this problem by going the pragmatically way and use some kind of software which dims the display to my preferred setting. There are a few applications to do this, but always it was necessary to drag a slider or type in a value to dim the display, so none of them allowed an automatic configuration. No, I am not a very sophisticated person, I only prefer to use software which is simply well-thought-out. And the winner is: brightness.
This tiny program works perfect and you will love its benefit by using it in terminal - yes, brightness is a command line utility. On top of this, brightness is able to control different displays, internal and external. The clou: beside using the precompiled binary you can also download the source code here, modify it to make the program fit your needs and then compile it using Xcode.

1. Installation
Download a precompiled version of the command line utility brightness here and extract the binary to your desired path (e.g. /usr/bin).

2. Usage
"brightness -l -v" dumps the current display attributes (-v for verbose mode) while "brightness 0.5" modifies the brightness of the main display to half of its max value and "brightness -m 1 1" let a second display become shiny. Just play little bit around.

3. Automatically launch
Sure, OS X provides different ways to launch a program automatically. If you are an enthusiast, feel free to use the one you prefer and stop reading, because you are already finished. If you are not that familiar to OS X take the next step as an advice.
An easy way to trigger OS X launching a program automatically is to add the desired program to your Login Items. But, in this case, it will not work the easy way, because we have to launch a so called classic command line utility with a given option. It is not like starting Mail or iCal, which appears as typical applications to OS X. You must start brightness via Terminal by typing "brightness 0.5" (without quotes) to modify the main display brightness to half of its max.
We now use a Launch Agent. Just create a .plist file, e.g. com.brightness.plist, with your favorite text editor. For the lazy ones here comes the template (simply copy and paste):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.brightness</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/brightness</string>
<string>.5</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Save the file in ~/Library/LaunchAgents, if you want brightness to be executed everytime you log in.
You could also use an AppleScript. Copy and paste this code "do shell script "brightness 0.5"" (without the leading and closing quotes) to a new Script. Then choose Save As and enable the Option to make it Execute only. Now add the Script to your Login Items.
Another option is to use a Terminal Script. Copy and paste this code
#!/bin/bash
/usr/bin/brightness 0.5
exit 0
and save it as, for example, brightness.sh. Make the Script executeable and add it to your Login Items.

That's it. Comments are welcome.

MBP 13" Mid 2010, Mac OS X (10.6.6)

Posted on Mar 3, 2011 3:28 AM

Reply
1 reply

May 26, 2014 8:47 AM in response to NilsP

Thanks. Works great. I made a ScriptBundle and a User Agent (launchd) . So if someone sets the display brightness to maximum, it automaticaly corrects it at next login.

The ScriptBundle contains your mentoined command line utility and the following applescript:


do shell script quoted form of (POSIX path of (path to resource "brightness")) & " 0.7"


Be aware of the space in " 0.7" or whatever value you have set.

Automatically adjust display brightness via Terminal / Pretty good solution

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.