Toggle Light Mode/Dark Mode AND Accent Color from one to another

Solution 1:

Maybe this applescript code will help a bit

tell application "System Preferences"
    reveal anchor "Main" of pane id "com.apple.preference.general"
end tell

tell application "System Events"
    repeat until exists of checkbox "Dark" of window "General" of application process "System Preferences"
        delay 0.1
    end repeat
    -- Appearance
    click checkbox "Dark" of window "General" of application process "System Preferences"
    -- Accent Color
    click checkbox "Red" of window "General" of application process "System Preferences"
    -- Dropdown Menu For Highlight Color
    click pop up button 1 of window "General" of application process "System Preferences"
    -- Highlight Color
    click menu item "Red" of menu 1 of pop up button 1 of window "General" of application process "System Preferences"
end tell

tell application "System Preferences" to quit

UPDATE:

Taking it one step further, save this following AppleScript code as an application. When this new app is launched, it allows for choosing your different color modes.

property appearanceMode : {"Light", "Dark"}
property accentColors : {"Blue", "Purple", "Pink", "Red", "Orange", "Yellow", "Green", "Graphite"}
property highlightColors : {"Blue", "Purple", "Pink", "Red", "Orange", "Yellow", "Green", "Graphite", "Other"}

activate
set chosenAppearanceMode to (choose from list appearanceMode ¬
    with title "Please Choose Your Appearance Mode" with prompt ¬
    "Please Choose Your Appearance Mode" OK button name ¬
    "OK" cancel button name "CANCEL") as string

if chosenAppearanceMode is "false" then return

activate
set chosenAccentColor to (choose from list accentColors ¬
    with title "Please Choose Your Accent Color" with prompt ¬
    "Please Choose Your Accent Color" OK button name ¬
    "OK" cancel button name "CANCEL") as string

if chosenAccentColor is "false" then return

activate
set chosenHighlightColor to (choose from list highlightColors ¬
    with title "Please Choose Your Highlight Color" with prompt ¬
    "Please Choose Your Highlight Color" OK button name ¬
    "OK" cancel button name "CANCEL") as string

if chosenHighlightColor is "false" then return

try
    if application "System Preferences" is running then do shell script "killall 'System Preferences'"
end try
repeat until application "System Preferences" is not running
    delay 0.1
end repeat

tell application "System Preferences" to reveal anchor "Main" of pane id "com.apple.preference.general"

tell application "System Events"
    repeat until exists of checkbox chosenAppearanceMode of window "General" of application process "System Preferences"
        delay 0.1
    end repeat
    -- Appearance
    click checkbox chosenAppearanceMode of window "General" of application process "System Preferences"
    -- Accent Color
    click checkbox chosenAccentColor of window "General" of application process "System Preferences"
    -- Dropdown Menu For Highlight Color
    click pop up button 1 of window "General" of application process "System Preferences"
    -- Highlight Color
    click menu item chosenHighlightColor of menu 1 of pop up button 1 of window "General" of application process "System Preferences"
end tell

try
    if application "System Preferences" is running then do shell script "killall 'System Preferences'"
end try

enter image description here


SIDENOTE: My reason for using the the do shell script "killall 'System Preferences'" command rather than tell application "System Preferences" to quit is... Let's say, for what ever reason, System Preferences.app is already activated (with, for example, window Sharing/ Remote Management/ Computer Settings open) but not visible or not front most or whatever. In Script Editor, you try to run tell application "System Preferences" to reveal anchor "SpeakableItems" of pane id "com.apple.preference.universalaccess" That command completes with no obvious errors but when you switch over to System Preferences, your "revealed anchor" is not revealed. Ok, no big deal, easy fix. I'll just insert a tell application "System Preferences" to quit command prior to the reveal anchorcommand. Running the updated code this time, you get a (userCanceledErr:-128) error. All of this hassle is because that secondary drop down window in System Preferences is open. In my opinion, the do shell script "killall 'System Preferences'" command seems to be the best solution.

Solution 2:

I've just tried to do the same thing and I believe this is not possible yet. In the Script Editor app you can see the "library" for documentation on the system events. It does mention the dark mode and highlight color, but not the accent color.

appearance preferences object n : A collection of appearance preferences properties
- appearance (blue/‌graphite) : the overall look of buttons, menus and windows - font smoothing (boolean) : Is font smoothing on?
- font smoothing style (automatic/‌light/‌medium/‌standard/‌strong) : the method used for smoothing fonts
- highlight color (blue/‌gold/‌graphite/‌green/‌orange/‌purple/‌red/‌silver or color) : color used for hightlighting selected text and lists
- recent applications limit (integer) : the number of recent applications to track - recent documents limit (integer) : the number of recent documents to track
- recent servers limit (integer) : the number of recent servers to track
- scroll bar action (jump to here/‌jump to next page) : the action performed by clicking the scroll bar
- smooth scrolling (boolean) : Is smooth scrolling used?
- dark mode (boolean) : use dark menu bar and dock