Yesterday night, I had put some big files for download. I needed a simple shutdown scheduler. Although I can enter the terminal command shutdown and enter the seconds to shutdown, I thought to do it using Keyboard Maestro in a much more elegant way.
Like this, I've also created a macro for sleep scheduling.
ShutdownAfter.kmmacros (2.3 KB)
SleepAfter.kmmacros (2.3 KB)
Both of these Macros ask me for input in minutes.
Any suggestions would be welcome.
Good macro. Generally you should not use a Typed String trigger for a macro that does not need a text context to type in to since the temptation would be to type it in the Finder for example, and then the deletes that Keyboard Maestro sends could do bad things.
This strikes me as the sort of macro that would be ideally suited to a Status Menu trigger, since “Shutdown After…” is exactly the kind of thing you’d expect to have in a menu.
September 7, 2017, 11:28am
The AppleScript has a delay of potentially several hours. Have you tested if this works reliably?
I have never used a script which such a long delay, and I can imagine that chances are good that it gets interrupted or that it hangs for some (unpredictable) reason.
I everytime use string triggers. So far, no problems for me. If anything accidentally happens, there’s CMD+Z. I’m too lazy to remember the shortcuts. The strings are easy on my hands and brain.
The status-bar idea seems great! I use Bartender so failed to think about it.
I tested it for upto 30 minutes. Never heard of unreliability of AppleScript.
If that’s the issue, perhaps we can add keystroke of Ctrl+Opt+Cmd+Eject/Power.
Can we use that user input variable in “pause” action?
Yes. Just type
Minutes * 60 into the Pause action.
Then follow that with the Shutdown actions, so no AppleScript needed.
September 8, 2017, 2:43pm
To trigger your macro you are actually executing these keystrokes:
; s h u t d o w n ; ⌫ ⌫ ⌫ ⌫ ⌫ ⌫ ⌫ ⌫ ⌫ ⌫
Even remotely thinking of doing this anywhere outside of a text input field makes the cold sweat roll down my face …
I use shutdown scheduling like only twice a week. Moreover, Keyboard Maestro hits those 10 deletes.
Since it is that infrequent, why not be safe and use
Trigger Macro by Name action (KM Wiki)?
You could probably select by just by typing “shut”.
For a detailed discussion, see this topic:
dangerous to use typed string triggers
I just set up one. Working great. With this, I need not remember exact string. Just got my hands on Keyboard Maestro 15 days ago. Thanks for introducing me this action.
Good to hear.
If that means you have revised your original macro you posted in your first post above, then please update that post with the revised macro.
I updated it with removed trigger string. Hope all is well.