Updated
How to Keep Your Mac Awake While an App Is Open
By Sindre Sorhus, who makes the Lungo app
With Lungo
On macOS 26 and later, the Shortcuts app can run a shortcut when an app opens or closes. Apple
- Install Lungo, and open it. Its icon is in the menu bar.
- In the Shortcuts app, make a shortcut with the “Set Enabled State” action of Lungo. Set it to turn Lungo on, and keep “Duration to Keep Lungo On” at “Indefinitely”.
- Make a second shortcut with the same action, set to turn Lungo off.
- Add an automation with the “App” trigger for when the app is opened, like Keynote, and choose the first shortcut.
- Add an automation with the “App” trigger for when the same app is closed, and choose the second shortcut.
Your Mac and its screen now stay awake while the app is open. To keep only the Mac awake, and let the screen turn off, like for a long download, set “Display Sleep” in the action to “Allow Display to Sleep”.
Tips
- The same way, you can turn Lungo on when your Mac connects to power (“Charger”), or joins a Wi-Fi network.
- Lungo stays in the menu bar, so you see when it is on. More ways to keep your Mac awake.
Get Lungo
Prevent your Mac from going to sleep
$4, one-time purchase
- Requires
- macOS 26 or later
- Privacy
- No data collected
- Family Sharing
- Yes
- Updated
- September 2026
- US App Store rating
- 4.9/5 (228 ratings)
Without an app
The caffeinate command of macOS keeps the Mac awake until a process ends. Open the Terminal app, and run this command with the name of the app, like Keynote:
caffeinate -i -w $(pgrep -x Keynote)
-i keeps the Mac from going to sleep, and -w stops when the app quits. Add -d to also keep the screen on. You must run the command again each time you open the app, and the app must be open before you run it.
