Adding Ambient Light Brightness Adjustment to External Monitors
macOS automatically adjusts the brightness of its built-in display according to the ambient light, but if you have an external monitor, its brightness will not be adjusted accordingly. As a result, the brightness difference between the two screens will become more noticeable as you work from day to night.
I’ve looked online for some open-source and commercial solutions, but I wasn’t satisfied with them, mainly because they all occupy a menu bar slot, which is unnecessary for a system that should automatically adjust its brightness. Additionally, some of these solutions come with features that are not really needed, such as color and temperature adjustments, and some even require a subscription just to sync the brightness levels.
This solution is very simple, using only AppleScript
and Shell
, and it has the following advantages:
- Automatically adjusts brightness levels
- Starts up automatically upon boot
- Does not occupy the dock or menu bar items.
Of course, there is still room for improvement due to my limited abilities:
- A more elegant way of obtaining the current brightness level of the system, currently using two regular expressions.
- Listening to system brightness adjustment events instead of monitoring them every 30 seconds with a timer.
Workflow
Prerequisites
- The monitor must support ddc/ci.
- The brightness adjustment tool provided by ddctl is needed:
|
|
Let’s begin
Scripting
Open the Script Editor
app, copy the code below, and save it as “AutoBrightness”:
|
|
Setup Launch at Login
System Preferences -> User & Groups -> (tab)Login Items -> Add AutoBrightness
Hide Application Icon
Right-click on AutoBrightness.app
-> Show Package Contents -> Contents
Open info.plist
Insert the following code in the first <dict></dict>
block, then save and exit.
|
|
EOF