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?

  • 1
    static let fade: CATransitionType The layer’s content fades as it becomes visible or hidden – Ruskes Oct 14 '18 at 17:41
  • 1
    Have you tried / considered using UI scripting? I imagine that would work. (You can prevent System Preferences from appearing by setting the window bounds to 00) – Wowfunhappy Oct 14 '18 at 19:26
  • 1
    @Wowfunhappy, That was from an old post of mine and does not need to be done, Just do not use activate with System Preferences, use e.g. reveal pane id "com.apple.preference.general" – user3439894 Oct 14 '18 at 20:39

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .