Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StayAwake ☕

Platform Swift License: MIT Dependencies

A tiny macOS menu bar app that stops your Mac falling asleep. One coffee mug, two states, no background work.

The StayAwake mug in the macOS menu bar: an outline mug when inactive, a filled mug when active

Icon State Behaviour
Outline mug Inactive Normal system behaviour
Filled mug Active Display sleep, screen saver and idle lock are blocked

Why

caffeinate -d in a terminal does the same job, but it ties the state to a window you have to keep around and gives you nothing to glance at. StayAwake is that command with a visible switch: one look at the menu bar tells you whether your Mac is going to stay up.

Usage

  • Left-click the mug to toggle.
  • Right-click for a menu: toggle, Launch at Login, Quit.
  • The state is remembered across restarts.

Launch at Login can also be set from the command line:

/Applications/StayAwake.app/Contents/MacOS/StayAwake --login-item on      # or off / status

If macOS reports requires approval, enable it under System Settings → General → Login Items.

Install

git clone https://github.com/marionuevo/StayAwake.git
cd StayAwake
./build.sh
cp -R build/StayAwake.app /Applications/
codesign --force --sign - /Applications/StayAwake.app
open /Applications/StayAwake.app

Re-signing after the copy matters — a moved bundle's ad-hoc signature can otherwise go stale and macOS will refuse to launch it.

Build

./build.sh          # produces build/StayAwake.app (universal arm64 + x86_64, ad-hoc signed)

Requires only the Xcode Command Line Tools (xcode-select --install) — there is no Xcode project and no package manager. The entire app is one Swift file, Sources/main.swift, compiled straight into a hand-assembled .app bundle by build.sh.

Minimum macOS is 13. The mug glyph (mug / mug.fill) is a macOS 15 SF Symbol, so on 13 and 14 the icon falls back to cup.and.saucer.

How it works

Active mode holds a single kIOPMAssertionTypePreventUserIdleDisplaySleep power assertion — the same mechanism behind caffeinate -d. The kernel tracks the assertion, so the app runs no timers and polls nothing: it sits at 0% CPU. Inactive mode releases it. The whole thing is one Swift file and a universal binary well under half a megabyte.

The assertion blocks idle sleep only. Manual locking (⌃⌘Q) and closing the lid still work in either state, and the assertion is released if the app quits or crashes, so there is no way to leave your Mac permanently awake by accident.

Verify what is holding your Mac awake at any time with:

pmset -g assertions | grep StayAwake

License

MIT © 2026 Mario Nuevo

About

A tiny macOS menu bar app that keeps your Mac awake. One coffee mug, two states, zero CPU — a single Swift file holding an IOKit power assertion.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages