Created
April 8, 2020 23:29
-
-
Save HanSooloo/259fa73a0755eddf985cff01e3d5bd9f to your computer and use it in GitHub Desktop.
AppleScript to change TrueTone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" | |
if (get name of every application process) contains "System Preferences" then | |
set _isSysPrefRunning to true | |
else | |
set _isSysPrefRunning to false | |
end if | |
end tell | |
log _isSysPrefRunning | |
use sys : application "System Events" | |
use prefs : application "System Preferences" | |
property prefsUI : a reference to process "System Preferences" | |
property _W : a reference to window "Built-in Retina Display" of prefsUI | |
property _TT : a reference to checkbox "True Tone" of tab group 1 of _W | |
property pane : "com.apple.preference.displays" | |
property anchor : "displaysDisplayTab" | |
property tab : anchor (my anchor) of pane id (my pane) | |
set TrueTone to null | |
if tab ≠ (reveal tab) then return null | |
tell _TT to if exists then set TrueTone to its value as boolean | |
click _TT | |
if _isSysPrefRunning is not true then | |
quit prefs | |
end if | |
tell application "BetterTouchTool" | |
if TrueTone then | |
set_string_variable "TrueToneState" to "Enabled" | |
else | |
set_string_variable "TrueToneState" to "Disabled" | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment