This script automatically adjusts the brightness of your displays via BetterDisplay when macOS switches between Light and Dark mode (e.g., at sunset).
AutoBrightness.swift: The main Swift script that listens for theme changes.com.nymphium.autobrightness.plist: LaunchAgent configuration to run the script in the background.
-
Compile the script:
mkdir -p ~/.local/bin swiftc AutoBrightness.swift -o ~/.local/bin/autobrightness
-
Install the LaunchAgent:
mkdir -p ~/Library/LaunchAgents cp com.nymphium.autobrightness.plist ~/Library/LaunchAgents/ launchctl load ~/Library/LaunchAgents/com.nymphium.autobrightness.plist
-
Verify: Check if it's running:
launchctl list | grep autobrightnessLogs can be found at
/tmp/com.nymphium.autobrightness.outand.err.
- BetterDisplay v2.2.x or newer (Pro features may be required for some CLI controls).
- BetterDisplay must be running and configured to accept CLI requests.