1

I've got a programme that I use regularly that has a really bad memory leak problem. It seems to be triggered when closing my laptop / putting it to sleep and then waking the laptop up again.

I wondered if it's possible to create an Automator workflow to say "when laptop is closed / when laptop goes to sleep close programme"?

1 Answer 1

1

Yes, this is possible. There are restrictions to performing scripts before sleep but it is possible.

Run a script on sleep

See Possible to run scripts on sleep and wake? for various tools that can run a script before sleep. I wrote, and thus recommend, Power Manager.

For the script, consider using AppleScript instead of Automator. Running an AppleScript before sleep will be simpler. The script could read:

tell application "MemoryLeak.app" to quit
2
  • Thanks Graham, reading the restrictions link you included is something like tell application "MemoryLeak.app" to quit considered a "quick action" ? Most of the time i dont go to apple > sleep or let the sleep timer kick in, but rather close the lid on my macbook pro, in the instance where i close the lid, will the command still run ?
    – sam
    Commented Feb 27, 2018 at 11:16
  • 1
    The AppleScript should be quick enough. I can only speak for Power Manager, but it will work for lid closing, Finder sleeping, and idle sleeping. Consider trying quit on wake first. Effectively this is the same outcome but less error prone. Commented Feb 27, 2018 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .