Re: Karabiner
Posted: 01 Jan 2022, 13:08
Oh yeah, tweaked the AppleScripts for toggling Auto Brightness:
And True Tone:
They provide immediate feedback even when System Preferences isn't already open now. I don't like laggy UIs!
Code: Select all
--Check if System Preferences already open?
--Don't want to quit it on exit if it's already running
if application "System Preferences" is running then
set appRunning to true
else
set appRunning to false
display notification "Automatic Brightness: Running…" with title "Automatic Display Brightness"
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.displays"
delay 2
end tell
end if
--Toggle Automatic Display Brightness
tell application "System Preferences"
set current pane to pane id "com.apple.preference.displays"
tell application "System Events"
tell process "System Preferences"
tell checkbox "Automatically adjust brightness" of group of window 1
click
--Display a matching notification
if value = {0} then
display notification "Automatic Brightness Disabled: Manual Override" with title "Manual Display Brightness"
end if
if value = {1} then
display notification "Automatic Brightness Enabled: Sensor Engaged" with title "Automatic Display Brightness"
end if
end tell
end tell
end tell
end tell
--Quit System Preferences if this script opened it up
if appRunning = false then
delay 1
tell application "System Preferences" to quit
end if
Code: Select all
--Check if System Preferences already open?
--Don't want to quit it on exit if it's already running
if application "System Preferences" is running then
set appRunning to true
else
set appRunning to false
display notification "True Tone: Running…" with title "True Tone"
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.displays"
delay 2
end tell
end if
--Toggle Automatic Display Brightness
tell application "System Preferences"
set current pane to pane id "com.apple.preference.displays"
tell application "System Events"
tell process "System Preferences"
tell checkbox "True Tone, Automatically adapt display to make colours appear consistent in different ambient lighting conditions." of group of window 1
click
--Display a matching notification
if value = {0} then
display notification "True Tone Disabled: Manual Override" with title "True Tone"
end if
if value = {1} then
display notification "True Tone Enabled: Sensor Engaged" with title "True Tone"
end if
end tell
end tell
end tell
end tell
--Quit System Preferences if this script opened it up
if appRunning = false then
delay 1
tell application "System Preferences" to quit
end if