Caffeinate
Keep your Mac and its display awake indefinitely, for a while, or until a set time, from the palette, the menu-bar cup or flow-cli.
On this page
Caffeinate keeps your Mac from going to sleep while it's idle: during a long build, an agent run, or a download. By default it keeps the display awake too. You can caffeinate indefinitely, for a duration, or until a time, from the command palette, the coffee cup in the menu bar, or flow-cli.
Start and stop
Open the palette (⇧⌘P) and type caf, coffee, awake or no sleep to list the Caffeine rows:
| Row | What it does |
|---|---|
| Caffeinate | Stay awake indefinitely (listed while off) |
| Decaffeinate | Let the Mac sleep again (listed while on) |
| Caffeinate for… | Pick or type a duration |
| Caffeinate until… | Pick or type a time |
| Caffeinate status | Shows the menu-bar cup (if hidden) and opens its menu |
| Caffeine in menu bar | Show or hide the coffee cup |
| Keep display awake | Whether runs keep the display on too |
Besides their labels, the rows come up when the first word you type (two characters or more) is the start of caffeinate, caffeine, coffee, awake, keep awake, no sleep, amphetamine or insomnia. sleep on its own doesn't count, so it still finds the system's Sleep action.
Every row is also an action you can bind in Settings › Keyboard; none has a default chord:
| Action | Setting key |
|---|---|
| Caffeinate | keyboard.caffeinate |
| Decaffeinate | keyboard.decaffeinate |
| Caffeinate for… | keyboard.caffeinate_for |
| Caffeinate until… | keyboard.caffeinate_until |
| Caffeinate status | keyboard.caffeine_status |
| Caffeine in menu bar | keyboard.toggle_caffeine_menu_bar |
| Keep display awake | keyboard.toggle_caffeine_display |
When a run starts, a toast confirms it ("Caffeinated indefinitely", or "Caffeinated until 6:00 PM · 1h 30m"). Decaffeinate shows "Decaffeinated — your Mac can sleep".
Type it inline
Type the whole request in the palette and press ↩ on the card it shows. A query that starts with caf (or any word starting with it, like caffeinate), awake, keep awake or coffee, followed by a duration or an until time, makes a card:
caf 90m
caffeinate 2h
keep awake 1:30
awake until 6pm
coffee till noon
The card shows when the run would end. In the palette a bare time needs until, till or til before it (caf 6pm makes no card).
Durations and times
Caffeinate for… takes a duration, and Caffeinate until… a time. Both drill-ins list presets under your query; ⇥, or → with the caret at the end, opens them from the highlighted row.
Durations:
90m,2h,1h 30m,1.5h,45s. Units areh/hr/hrs/hour/hours,m/min/mins/minute/minutesands/sec/secs/second/seconds.- A bare number is minutes:
90. 1:30(hours and minutes),half hour,half an hour,an hour.- At most 48 hours.
- Presets: 15 minutes, 30 minutes, 1 hour, 2 hours, 4 hours, 8 hours, 12 hours.
Times:
6pm,6:30pm,6p,17:30,1730,930am. A leadinguntil,tillortilis fine.eodorend of day(6:00 PM),noon,midnight(12:00 AM tomorrow).tomorrow(ortmrw) anywhere moves the time to tomorrow:tomorrow 9am.- A time that has already passed today means tomorrow.
- Without am/pm or a leading zero, an hour under 12 that has already passed today means the afternoon:
6at 2 PM is 6 PM.09:00and0030are read as 24-hour times. - Presets, in the order they fall: End of day, Midnight, Tomorrow morning (9 AM), Lunch (noon).
The menu-bar cup
While Caffeine in menu bar is on (the default), a coffee cup sits in the macOS menu bar: with steam while caffeinated, crossed out and dimmed while not. Beside it, a countdown shows the time left (∞ for an indefinite run). Its tooltip is the current status, such as "Caffeinated (1h 29m left) · until 6:00 PM · display on".
Click the cup for its menu:
- Decaffeinate while on, or a dimmed "Not caffeinated".
- Caffeinate: Indefinitely, 10 Minutes, 30 Minutes, 1 Hour, 2 Hours, 4 Hours, 8 Hours, 12 Hours, and Custom…, which opens the palette with
caftyped so you can enter any duration or time. - While on, a checked line with the current run: "Until 6:00 PM — 1h 29m remain" or "Indefinitely — 5m 3s so far".
- Keep display on (
⌥Dwhile the menu is open). - Hide from menu bar. Bring the cup back with the palette's Caffeine in menu bar or Caffeinate status.
How a run behaves
- Caffeinate holds a macOS power assertion against idle system sleep, plus one against display sleep while Keep display awake is on. Both are named "Flow Caffeinate", which is how they appear in
pmset -g assertions. - Turning Keep display awake on or off during a run changes that run too, as well as later ones.
- A timed run ends by itself. Flow then tells you "Caffeine wore off — your Mac can sleep". That message is the
caffeinatenotification kind (a toast by default); change how it's delivered in Settings › Notifications (see Notifications and snooze). - Quitting Flow releases the assertions, so your Mac can sleep again. A run that hasn't expired resumes when Flow next launches; one that expired in the meantime is cleared without a message.
- While Flow is locked behind the paywall no run can start, the assertions are released and the cup is hidden. The run is kept and resumes once Flow is unlocked, unless it expired in between.
From the command line
flow-cli caffeinate takes the same durations and times:
flow-cli caffeinate on # indefinitely
flow-cli caffeinate 90m # for 90 minutes (also 1:30, 2h)
flow-cli caffeinate until 6pm # until a time (also until eod, until tomorrow 9am)
flow-cli caffeinate 6pm # a bare time that isn't a duration also works here
flow-cli caffeinate off # let the Mac sleep
indefinitely and indefinite mean on; stop means off. The reply has the caffeine state and its status line. See flow-cli.
Settings
Caffeinate's settings have no rows in the Settings window. Change them with the palette rows and the cup's menu, or with flow-cli settings set:
| Key | Type | Default | Effect |
|---|---|---|---|
caffeine.display | boolean | true | Runs keep the display awake too (Keep display awake, the menu's Keep display on) |
caffeine.menu_bar | boolean | true | Show the coffee cup in the menu bar (Caffeine in menu bar, Hide from menu bar) |
caffeine.menu_bar_timer | boolean | true | Show the countdown beside the cup |
For example, to keep the cup but drop its countdown:
flow-cli settings set caffeine.menu_bar_timer false
Flow also stores the current run under caffeine.state (absent while off); don't edit it by hand. Use the actions instead.
Sources
Written from these files in the Flow app repo
src/caffeine.rssrc/caffeine_app.rssrc/caffeine_sys.rssrc/command.rssrc/pages.rssrc/notifications.rssrc/bus.rssrc/bin/flow-cli.rs