Feature Suggestion: Toggle System Night Shift / App Supplement Meanwhile

"Toggle System Dark Mode" in KM has been great :).

I have a feature suggestion of adding an action of "Toggle System Night Shift".

For now, I've resorted to using Shifty to shortcut(verb) night shift. Shifty's code is open source to look at.

This KM forum post (Toggle Night Shift) used AppleScript but no longer works with the Monterey layout, and goes through popping up and closing down System Preferences.

I know you are asking about Night Shift, not Dark Mode, but I wish to make a comment about both.

As far as I can tell, KM toggles Dark Mode using the following code inside it's Toggle Dark Mode action. Here's an image of the action followed by the AppleScript that probably implements it:

I googled how to toggle Night Shift. And the code is slightly more complicated:

Notice that this code requires that the System Preferences Panel be open. (And then it closes it.) This is probably not what you want. But if this is a requirement of the AppleScript, then this is the best KM could do. Since this is ugly, that may be why KM doesn't implement it. Are you satisfied with this code? If you are satisfied, then you can use the code in your own macro to get the job done. You could create a subroutine to implement this. I recommend that if you pass the subroutine a "1" it enables Night Shift, a "0" would disable it, and an empty parameter would toggle it. That's my advice.

Also, I can't test the code because Night Shift works with only five different models of monitor, and I don't have any of them. I've heard from some Youtube channels that Apple may be offering some new models of monitors in two weeks. I might buy one.

As always, there's a 20% chance I'm wrong on anything I say. So take this as a non-authoritative answer.

EDIT: the code for Night Shift, above, may work on an older version of MacOS, not the current version. In any case, it won't make you happy because it requires System Preferences to be open.

Not satisfied with the code, I’ve been aware of the AppleScript you mention for a while (I know google too :wink:). Unfortunately, is slow to start and then also cascades across the UI slow too, or as we both mentioned needs system preference to be open or move through system preferences / doesn’t work with new versions. (i.e. problems)

At the risk of repeating myself this is why I mentioned Shift (which somehow does night shift change gracefully/reliably). Maybe I should have been clearer, since Shift’s code is open source it’s code could be incorporated into KM as a new action.

KM might include open source code, but ONLY if the open-source code doesn't use any undocumented APIs. I spent 5 minutes browsing Shifty files on Github but I was unable to determine (because I'm not smart enough) if it refrained from using undocumented APIs. The method that I demonstrated used visible APIs through AppleScript.

Sorry if I'm repeating myself. Sorry if my response was too elementary for you. I often try to jump in the deep end and try to answer questions that I'm not qualified to answer. Sometimes it works, and sometimes it doesn't.

Did you know that KM doesn't use undocumented APIs?

I remember reading about it somewhere on here, makes sense that KM only uses documented APIs though, probably one of the reasons why KM is so stable :muscle:.

I think you can still run KM v3 on MacOS without problems. Most likely you can't say that about Shifty. :slight_smile:

1 Like