AppleScript to toggle dark mode with fading

applescriptdark mode

I have a script to toggle dark mode using

tell application "System Events"
    tell appearance preferences 
        set dark mode to not dark mode 
    end tell
end tell

However, this causes every application to instantly change from light to dark mode, as soon as it can. If I use the system preferences to toggle dark mode, all apps simultaneously have a slow fade from light to dark mode (or vice versa). Though this is a very minor aesthetic change, I would like to have the fade occur when I use my script to toggle dark mode. Is there a way to toggle dark mode the same way system preferences does so that it initiates the fading toggle?

Best Answer

I believe at the moment this is not possible. Even when you switch between Dark/Light modes in Automator, it will call the same API that your AppleScript does and change it immediately. Which makes me believe if Apple didn't make it fade nicely for its own tool, it currently can't be done.