Disable True Tone and Auto Brightness with a script

JRM5513
New Contributor III

Blackground :
We deal with lots of designers and video editors at my company and they can't do a proper white balance with True Tone. As far as I know, there is no MDM key to manage this setting.

Solution :
I created an Apple Script (embedded in a bash script) that will open and automatically click the right menus in order to turn off True Tone and Auto Brightness. It only works with an English UI but you'll find a French version on my website. It was written for macOS Monterey and Ventura.

Scripts : disable_truetone_english.sh
Blog post : https://clementine.la/scripts/desactiver-true-tone-par-script/

 

 

 

#!/bin/bash

###
#
#                Author : https://clementine.la
#               Created : 2022-09-09
#         Last Modified : 2022-10-24
#               Version : 2.0
#           Tested with : macOS 12.6 / macOS 13.0
#
###

# Read logged in user
loggedInUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
echo "Hello, I am $loggedInUser"

# Read macOS version
macos=$(sw_vers -productVersion)

#############
# FUNCTIONS #
#############

# Disable True Tone & Auto Brightness
# Doesn't work if you have an external monitor plugged in

truetone_monterey() {
open "/System/Applications/System Preferences.app"
sleep 3
open "/System/Library/PreferencePanes/Displays.prefPane"
sleep 1

sudo -u "$loggedInUser" osascript -e '
activate application "System Preferences"
tell application "System Events"
	tell process "System Preferences"
		
		repeat until exists group 1 of window "Displays"
		end repeat
		
		if (value of checkbox "Automatically adjust brightness" of group 1 of window "Displays" as boolean) then
			click checkbox "Automatically adjust brightness" of group 1 of window "Displays"
		end if
		
		if (value of checkbox "True Tone, Automatically adapt display to make colours appear consistent in different ambient lighting conditions." of group 1 of window "Displays" as boolean) then
			click checkbox "True Tone, Automatically adapt display to make colours appear consistent in different ambient lighting conditions." of group 1 of window "Displays"
		end if
	
	end tell
	delay 1.0
	quit application "System Preferences"
end tell
'
}

truetone_ventura() {
open "/System/Applications/System Settings.app"
sleep 3
open "/System/Library/PreferencePanes/Displays.prefPane"
sleep 1

sudo -u "$loggedInUser" osascript -e '
activate application "System Settings"
tell application "System Events"
	tell process "System Settings"
		
		repeat until exists group 1 of window "Displays"
		end repeat
				
		if (value of checkbox 1 of group 2 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays" as boolean) then
			click checkbox 1 of group 2 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays"
		end if
		
		if (value of checkbox 2 of group 2 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays" as boolean) then
			click checkbox 2 of group 2 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays"
		end if
		
	end tell
	delay 1.0
	quit application "System Settings"
end tell
'
}

#################
# END FUNCTIONS #
#################

if [[ "$macos" == "12."* ]]; then
	echo "MONTEREY"
	truetone_monterey
elif [[ "$macos" == "13."* ]]; then
	echo "VENTURA"
	truetone_ventura
else
	echo "UNKNOWN OS"
	exit 0
fi

exit 0

 

 

 

 

5 REPLIES 5

RPH777
New Contributor

I'm getting an error when I run it.

587:594: execution error: System Events got an error: Can’t get checkbox 2 of group 2 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays" of process "System Settings". Invalid index. (-1719)

RPH777
New Contributor

Worked great on a machine with Auto Brightness and True Tone.  Maybe thats the issue my iMac doesn't have True Tone. Thanks for this it's exactly what I needed!

JRM5513
New Contributor III

The script is not really robust I admit, it expects the 2 settings in the opened window. If you want to keep True Tone on or if your Mac doesn't support it, you can remove the following lines from the script :

 

		if (value of checkbox 2 of group 2 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays" as boolean) then
			click checkbox 2 of group 2 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays"
		end if

 

 

RPH777
New Contributor

Any solution if we have 2 displays running?

sdfwww1
New Contributor

Hi! Thanks for the script! Is there any way I can launch it via Shortcut?
I tried pasting the script or launch it via file (chmod +x), doesn't work