I'm running BigSur 11.7.5.
I want to run some sort of command or script from the command line which will dismiss the screen saver, but only if the screen saver is active. If the screen saver is not active, then I would like this command or script to be an effective no-op.
I intend to invoke the command or script via a non-interactive ssh session when I am not in front of the Mac, and therefore, I never know at invocation time whether or not the screensaver is active when I ssh in to run the command or script.
One of the commonly mentioned ways to dismiss the screensaver is to use osascript to send a click or a newline character. However, if the screensaver is not active, that click or newline could affect the behavior of some existing app which might be open on the Mac's screen.
This is why I'm looking for a way to dismiss the screensaver via the command line if it's active, and perform a no-op if it's not active.
Thank you in advance for any suggestions.
key code 55
, i.e. command key. Unlike 'return' or 'click', it shouldn't be treated as an action by any apps (that I'm aware of) but it will stop the screen saver.