I created this little macro to toggle dark mode on Mojave. After checking the OS version, it runs a short appleScript to toggle the Dark Mode state. If not running Mojave or later, the macro exits with a notification.
Thanks for sharing this. I think many Mojave users will find this useful. Out of curiosity, why did you limit this to Mojave (and above) ? High Sierra has dark mode too—in a more limited capacity—and it is set via AppleScript using exactly the same code.
I see the macro starts off by executing an AppleScript, then breaking out of it to do a regular expression search before going back in to another AppleScript. As a small hint or tip, you can isolate the major version number like so:
set text item delimiters to "."
set OSMajorVer to text item 2 of system version of (system info)
Then, of course, follow it with:
if the OSMajorVer < 14 then return false
tell application "System Events" to tell ¬
the appearance preferences to ¬
set dark mode to not dark mode
Forgive me if you already knew about text item delimiters and simply chose to use more core KM actions out of personal preference.
Thanks for the suggestions. This was my first macro posted to the site as I am fairly new to Keyboard Maestro. I am familiar with the text item delimiters approach within AppleScript. I haven't done much AppleScript coding in a while, so it didn't dawn on me at the time. I did want to play with the RegEx capabilities within KBM. It is a very flexible utility, so lots of ways to get to the same end.