Dark mode not working because of previous AppleScript

Hi All,

I used the following AppleScript last year when Mojave came out to create a keyboard shortcut to toggle between Dark Mode:


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

Now, I’m attempting to use the Auto Appearance feature in Catalina for dark mode, but “Auto” seems to be the same as Dark appearance.

The value that appears in the System Preferences > General screen does not always match the actual status. For example, if I set the System Preferences screen to Light mode, run the Apple Script and set it to Dark, the System Preferences screen remains selected on Light.

So the question is – how can I delete this variable set by AppleScript? I tried creating another script and setting it to null, “”, missing value, but none of these works. Is there a command in Apple Script to make it forget the value, or a file I can physically modify or remove on the hard drive to get rid of it?

This issue is specific to the account I ran this on, as I created a new account as a test and it successfully set the appearance based on time of day when on the Auto settingo n that new account. It also does not seem the value is stored anywhere in ~/Library, as I tried moving that directory temporarily, everything reset, but the behavior of this setting did not change.

Thank you in advance for any assistance you can provide!

I tried quitting System Events but no luck.

I had it setup as a Keyboard Shortcut but removed it the evening I installed Catalina. But I’ve been running the script manually from the command line since then.