← Blog Mac Productivity

How to Keep a Mac Awake: 5 Ways (Lid Closed Too)

By FavTray · · Updated

Written by the team behind FavTray, a Mac developer dashboard for the menu bar. We check every app we cover against its own site, docs or a hands-on test, and each post says which.

Short answer: to keep a Mac awake right now, open Terminal and run caffeinate -d (Ctrl+C stops it). To keep it awake for good, set System Settings > Lock Screen > “Turn display off on power adapter when inactive” to Never. For a menu bar toggle, KeepingYouAwake and Amphetamine are free; only Amphetamine works with the lid closed.

TL;DR

  • Quickest, built in: caffeinate -d in Terminal. All the flags.
  • Always on while plugged in: System Settings, Lock Screen and Battery (steps in Method 1).
  • Free one-click toggle: KeepingYouAwake, still maintained in 2026.
  • Triggers or lid closed: Amphetamine.
  • Stay “Active” in Slack or Teams: simulated input, like FavTray’s Keep Alive.

Below are five ways to keep a Mac awake, from simplest to most capable, then the options for a closed lid and a quick way to check what is holding your Mac awake.

Method 1: How Do You Change Mac Sleep Settings in System Settings?

The settings live in two places: Lock Screen controls when the display turns off, and Battery (on a MacBook) or Energy (on a desktop Mac) controls whether the Mac sleeps once the display is off. The labels below are the same on macOS Tahoe (26) and macOS 27, per Apple’s sleep and wake settings guide.

Steps:

  1. Open System Settings > Lock Screen
  2. Set “Turn display off on power adapter when inactive” (MacBook) or “Turn display off when inactive” (desktop Mac) to Never, or to a longer duration
  3. MacBook: go to Battery > Options and turn on “Prevent automatic sleeping on power adapter when the display is off”
  4. Desktop Mac: go to Energy and turn on “Prevent automatic sleeping when the display is off”

Pros: Built-in, no downloads, persists across restarts. Cons: Permanent setting — easy to forget you changed it. No quick toggle or schedule. On battery, a MacBook still sleeps once the display turns off.

Method 2: How Do You Use the Caffeinate Command in Terminal?

The caffeinate command is a built-in macOS utility that prevents sleep from Terminal. It uses the same IOKit power assertions that apps use, needs no installation, and its man page lists separate assertions for display, idle, disk and system sleep. Our full caffeinate command guide covers all seven flags; the everyday ones are below.

Basic usage:

## Keep Mac awake indefinitely (Ctrl+C to stop)
caffeinate

## Keep awake for 2 hours (7200 seconds)
caffeinate -t 7200

## Keep awake while a process runs
caffeinate -w $(pgrep -f "your-process-name")

## Prevent display sleep specifically
caffeinate -d

## Prevent idle sleep (allows display to sleep)
caffeinate -i

## Combine flags: prevent display and idle sleep for 1 hour
caffeinate -di -t 3600

Flag reference:

FlagEffect
-dPrevent display sleep
-iPrevent idle sleep
-mPrevent disk sleep
-sPrevent system sleep (AC power only)
-t NTimeout after N seconds
-w PIDStay awake while process PID is running

Pros: Built-in, no downloads, very flexible, scriptable, no admin access needed. Cons: Needs a Terminal window left open. No visual indicator. Easy to forget it is running. Does not generate mouse activity for app-level idle detection, and does not keep a closed MacBook awake.

Method 3: How Does Amphetamine Keep Your Mac Awake?

Amphetamine is a free menu bar app on the Mac App Store. Beyond simple on/off sessions, it has triggers that start a session automatically (a Wi-Fi network, a running app, an external display, battery level, power adapter, CPU use and more), a Closed-Display Mode that keeps a MacBook awake with the lid shut, and an optional setting that moves the cursor periodically.

Pros: Free, trigger-based automation, lid-closed support, optional cursor movement. Cons: A lot of settings for what is often a one-click job.

For how it compares with FavTray’s approach, see FavTray vs Amphetamine.

Method 4: KeepingYouAwake, the free one-click toggle

KeepingYouAwake is a free, open-source menu bar app that wraps the caffeinate command in a one-click interface. Click the cup icon to toggle sleep prevention, or pick a duration from its menu. Install it from GitHub or with brew install --cask keepingyouawake. Its README is clear that it only prevents sleep on desktop Macs and on MacBooks with the lid open.

Is KeepingYouAwake still maintained? Yes. When we checked on 28 September 2026, the latest release was 1.6.8 (September 2025, with a macOS 26 Tahoe icon) and the GitHub repository had commits from August 2026. Our KeepingYouAwake guide covers installing it, its URL scheme and macOS 27, and KeepingYouAwake alternatives compares what to use instead.

Pros: Free, open-source, minimal, low resource use. Cons: No triggers, no scheduling, no mouse movement, no lid-closed mode.

We compare the two free apps head to head in KeepingYouAwake vs Amphetamine.

Method 5: How Does FavTray’s Keep Alive Prevent Sleep?

FavTray’s Keep Alive does two things at once: it holds a sleep assertion, like caffeinate, and it moves the cursor a few pixels (5 by default) at an interval you set. The assertion keeps macOS awake; the simulated input keeps apps with their own idle detection, like Slack, Microsoft Teams and Zoom, from marking you Away. It can pause while you are using the mouse, pause on battery, or run only during office hours.

Keep Alive needs Accessibility permission, because that is how macOS lets an app move the cursor. You toggle it from the FavTray menu bar icon, alongside the app’s other tools such as the eye rest timer and AI usage tracking. If what you want is closer to a hardware jiggler, our guide to mouse jigglers covers the trade-offs, including what IT can see.

Pros: Prevents both OS sleep and app-level idle timeouts. Scheduling and battery-aware pausing. Bundled with other developer utilities in a single menu bar icon. No account, and no FavTray server stores your data. Cons: The cursor shifts slightly. Free for 3 hours a day; FavTray’s one-time Lifetime licence (pricing) removes the limit, and every install gets a 7-day trial of everything.

Which way to keep your Mac awake should you choose?

MethodPrevents OS SleepKeeps Slack/Teams ActiveLid ClosedMenu Bar ToggleSchedulingCost
System SettingsYes (on power)NoNoNoNoFree
caffeinateYesNoNoNoTimeout onlyFree (built in)
AmphetamineYesOptional cursor movementYesYesYes (triggers)Free
KeepingYouAwakeYesNoNoYesDuration onlyFree
FavTray Keep AliveYesYesClamshell onlyYesYes (office hours)Free 3 h a day; one-time Lifetime licence

For a deeper comparison of the dedicated apps, see our Mac keep alive app comparison.

Choose System Settings if you always want your Mac awake on AC power and do not care about per-session control.

Choose caffeinate if you are comfortable in the terminal and want a quick, scriptable solution for occasional use.

Choose Amphetamine if you want trigger-based automation — for example, automatically preventing sleep on your office Wi-Fi — or need a MacBook awake with the lid closed.

Choose KeepingYouAwake if you want the simplest possible GUI with zero learning curve.

Choose FavTray if you need to stay active in Slack/Teams, want keep-alive bundled with an eye rest timer and AI tracking, or want to reduce your total menu bar app count.

How Do You Keep a Mac Awake With the Lid Closed?

A MacBook sleeps when you close the lid, and most keep-awake tools do not change that. Apple’s IOKit documentation says the idle-sleep assertion that caffeinate creates still lets the system sleep on lid close, and KeepingYouAwake’s README says it does not support a closed lid. These three options do work:

  1. Clamshell mode (Apple-supported). Connect the power adapter, an external display, and a USB or Bluetooth keyboard or mouse. Once the desktop appears on the external display, close the lid. Apple lists these requirements in its external display troubleshooting guide. On an Apple silicon MacBook, approve the keyboard or mouse the first time you connect it.
  2. Amphetamine’s Closed-Display Mode. Keeps a MacBook awake with the lid closed and no external display. Plug in for anything long.
  3. pmset in Terminal. sudo pmset -a disablesleep 1 stops the Mac sleeping for any reason, lid included. Undo it with sudo pmset -a disablesleep 0. The option is not in the pmset man page, it needs an admin password, and a Mac that cannot sleep will stay on in a bag, running hot and draining the battery. Set a reminder to turn it off.

FavTray’s Keep Alive keeps running in clamshell mode, which suits a docked setup where you step away but want Slack or Teams to show you as available. It does not override lid-close sleep on its own.

How Do You Check What Is Keeping Your Mac Awake?

Run this in Terminal:

pmset -g assertions

The top section counts active assertions by type (PreventUserIdleSystemSleep, PreventUserIdleDisplaySleep and others). Under “Listed by owning process” you see who holds each one — caffeinate, Amphetamine, a video call, a backup. It is the fastest way to confirm a keep-awake tool is working, or to find the app that is stopping your Mac from sleeping.

How Do You Stop Your VPN from Disconnecting When Your Mac Sleeps?

VPN disconnections during Mac sleep are one of the most common complaints among remote workers, especially those using enterprise clients like Cisco AnyConnect, Palo Alto GlobalProtect, or Pulse Secure. The root cause is straightforward: when macOS enters sleep mode, it powers down network interfaces to conserve energy. Once the Wi-Fi or Ethernet adapter goes offline, your VPN tunnel collapses and has to renegotiate from scratch when the Mac wakes up — often requiring re-authentication.

The caffeinate -s flag prevents system sleep while on AC power, which keeps network interfaces alive. However, -s alone does not prevent idle sleep when running on battery, and it does not generate any input activity. If your corporate VPN client or endpoint management software has its own idle timeout independent of macOS sleep, caffeinate will not help.

FavTray’s Keep Alive covers both layers: its sleep assertion keeps network interfaces powered and the tunnel up, and its simulated input resets app-level idle timers. It needs no admin password, but it does need Accessibility permission, which IT may manage on a company Mac.

If you are troubleshooting persistent VPN drops, check whether your IT department has configured a separate inactivity timeout on the VPN gateway itself. No client-side keep-alive tool can override a server-side session timeout — you will need your network admin to adjust that policy.

Can You Prevent Sleep on a Schedule?

Yes. For scheduled prevention, you can combine caffeinate with cron or launchd, or use Amphetamine’s trigger system. For example, to prevent sleep every weekday from 9 AM to 6 PM, create a LaunchAgent plist that runs caffeinate -t 32400 at 9 AM.

FavTray’s Keep Alive can follow office hours you set, or you can toggle it from the menu bar when a task needs it.

The right approach depends on your workflow. For most developers the need is tied to a task rather than the clock, so a quick toggle — a menu bar app or a terminal alias — covers it without scheduled automation.

Frequently Asked Questions

How do I keep my Mac awake?

For a one-off, open Terminal and run caffeinate -d; the Mac stays awake until you press Ctrl+C. To keep it awake permanently on power, set System Settings > Lock Screen > 'Turn display off on power adapter when inactive' to Never and, on a MacBook, turn on Battery > Options > 'Prevent automatic sleeping on power adapter when the display is off'. For a menu bar toggle, install KeepingYouAwake or Amphetamine (both free).

Is KeepingYouAwake still maintained?

Yes. As of 28 September 2026 its latest release is 1.6.8 (12 September 2025), which added a macOS 26 Tahoe icon, and its GitHub repository received commits as recently as 15 August 2026. It is free, open source and installs with brew install --cask keepingyouawake. It can't keep a MacBook awake with the lid closed, by design.

KeepingYouAwake vs Amphetamine: which should I use?

KeepingYouAwake if you want a one-click cup icon and nothing else: it's free, open source and has almost no settings. Amphetamine if you want triggers (start a session on a Wi-Fi network, app or display), a closed-lid mode or optional cursor movement: it's free on the Mac App Store. Neither stops Slack or Teams from marking you Away unless you turn on Amphetamine's cursor movement.

How do I keep my Mac awake without touching the mouse?

Run caffeinate in Terminal, or turn on KeepingYouAwake or Amphetamine: all three hold a sleep assertion, so macOS stays awake with no input at all. If an app such as Slack or Teams also needs to see you as Active, you need simulated input, such as FavTray's Keep Alive or Amphetamine's optional cursor movement.

Does keeping your Mac awake damage the battery?

Keeping your Mac awake does not damage the battery directly, but it does consume more power. Modern MacBooks use lithium-ion batteries with built-in charge management. The main concern is heat — if your Mac runs intensive tasks while preventing sleep, sustained heat can degrade battery health over time. For overnight processes, keep your Mac plugged in.

Can you keep your Mac awake without admin access?

Yes. The caffeinate Terminal command, Amphetamine and KeepingYouAwake all work without an admin password, because they use the same IOKit power assertions as caffeinate. FavTray's Keep Alive also needs no admin password, but it asks for Accessibility permission because it moves the cursor; on a company Mac, IT may manage that permission.

Does preventing Mac sleep keep you active on Slack and Teams?

Not on its own. Slack and Teams mark you Away after a stretch with no keyboard or mouse input, even while the Mac is awake. Slack's developer docs, for example, say a user is marked away after 10 minutes with no activity. Staying Active needs simulated input, such as FavTray's Keep Alive or Amphetamine's optional cursor movement.

How do I keep my MacBook awake with the lid closed?

There are three ways. Clamshell mode is the one Apple supports: connect the power adapter, an external display, and a keyboard or mouse, then close the lid. Amphetamine's Closed-Display Mode keeps a MacBook awake with the lid closed without an external display. In Terminal, sudo pmset -a disablesleep 1 stops all sleep until you run sudo pmset -a disablesleep 0. The last two keep the Mac awake even in a bag, so watch heat and battery. caffeinate and KeepingYouAwake do not keep a closed MacBook awake.

How do I check what is keeping my Mac awake?

Run pmset -g assertions in Terminal. Under 'Listed by owning process' it shows every app or command holding a sleep assertion, such as caffeinate, Amphetamine or a video call, and which kind of sleep each one blocks.

How do I stop my VPN from disconnecting when my Mac sleeps?

Prevent system sleep with caffeinate -s (on power), Amphetamine or FavTray's Keep Alive. VPN clients like Cisco AnyConnect and GlobalProtect disconnect because macOS disables network interfaces during sleep, so keeping the system awake keeps the tunnel up. A timeout set on the VPN server itself can still end the session.

Something new: My Dock Buddies