The way you can accomplish this
- Brightness control program (can be installed via Homebrew or compiled from source)
- A per user bash script that set's the brightness
- Script Added to
~/Library/LaunchAgents
and loaded with launchd
OR
There is an AppleScript method that you can use instead of using the brightness program reference above. I am not a fan of this method because I have not found AppleScript to be as reliable as bash (things break when Apple does updates). Scroll to the bottom for details.
Install Brightness
If you have Homebrew, issue the command brew install brightness
. If compliling from source, download from the link provided then compile.
cd /brightness ---- (or whereever you downloaded the source)
make
sudo make install
Test it out by issuing some brighness commands:
brightness 1 <------- set to 100%
brightness .5 <------- set to 50%
Write a bash script to be executed when you log in
#!/bin/bash
/<path-to-brightness>/brightness .75
sleep 20 # I put this here because I find lauchd needs some "time"
exit 0
Do this for each user and place the script in an easily accessed location. For example, create a "scripts" directory in each user's home directory:
/Users/<username>/Scripts/set_brightness.sh
This is just an example, you can place the script anywhere you like, but remember, you need one that is executable by each user. Speaking of "executable" make sure you set the permissions of the script to execute - chmod +x set_brightness.sh
Be sure to test out by executing the script directly from the command line by calling it:
$ ./set_brightness.sh
Your screen brightness should change to the setting in the script(make sure you change the setting manually first to make sure you are not changing it to what it already is).
Create a .plist file and Load to launchd
Your .plist will execute every time you log in, so it must be located in the ~/Library/LaunchAgents directory. As for the filename, my preference is to use something like the following:
com.user.setbrightness.plist
The .plist should look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.brightness</string>
<key>KeepAlive</key>
<key>RunAtLoad</key>
<true/>
<key>Program</key>
<string>/Users/<username>/<location of script>/set_brightness.sh
</dict>
</plist>
Load the .plist to launchd
launchctl load com.user.brightness.plist
Do this for each user so that every time the user logs in it will execute the bash script setting the brightness automatically.
Alternative Method (for 5K monitors)1
You can also do this via AppleScript and skip the brightness program altogether (I tested this on a non-5K iMac running 10.11.6 and it works).
AppleScript Code:
tell application "System Preferences"
activate
reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
tell application "System Events"
delay 1
set value of slider 1 of group 1 of tab group 1 of window 1 of process "System Preferences" to 0.5
end tell
quit
end tell
Save this AppleScript in the same way as described above.
Make this change to your .plist (relacing Program with ProgramArguments):
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>path-to-script/set_brightness.scpt</string
</array>
1 Adapted from this post:
Is it possible for an Applescript to dim/up 0%/100% screen brightness on OSX 10.9 Mavericks when connected to external display?