DoNotSleep is a minimal macOS menu bar app written in Swift. It uses caffeinate to keep the Mac awake and can be toggled directly from the status bar.
- Left click on the tray icon toggles
Do Not Sleepon and off. - Right click opens the menu with explicit toggle and quit actions.
- The tray icon changes between
💤and☀️to reflect the current state. - The app bundle includes a generated
.icnsapp icon. - Quitting the app cleanly stops the running
caffeinateprocess.
- macOS
- Xcode Command Line Tools or Xcode with
xcrun swiftc
Install the command line tools if needed:
xcode-select --installCreate a macOS app bundle in build/DoNotSleep.app:
./build_app.shThe generated bundle contains:
build/DoNotSleep.app/Contents/Info.plistbuild/DoNotSleep.app/Contents/MacOS/DoNotSleepbuild/DoNotSleep.app/Contents/Resources/DoNotSleep.icns
You can launch it from Finder, with open, or with the helper script below.
Start the app with the helper script:
./launch.shThe script builds build/DoNotSleep.app when needed and launches the bundled app in the background.
Build a versioned zip in dist/ for GitHub Releases:
./package_release.shThis produces:
dist/DoNotSleep-<version>-macos.zipdist/DoNotSleep-<version>-macos.zip.sha256
The version is read from Info.plist by default.
On GitHub Actions tag builds like v1.0.1, the tag version is used automatically for both the zip name and the bundled app metadata.
You can override it locally with VERSION=1.0.1 ./package_release.sh.
Sign the app bundle locally with a Developer ID certificate:
SIGN_IDENTITY="Developer ID Application: Your Name (TEAMID)" ./codesign_app.shOr sign while packaging the release zip:
SIGN_IDENTITY="Developer ID Application: Your Name (TEAMID)" ./package_release.shThe signing script runs:
codesign --force --deep --options runtimecodesign --verifyspctl --assess
./build_app.sh
open build/DoNotSleep.appmkdir -p build/DoNotSleep.app/Contents/MacOS build/DoNotSleep.app/Contents/Resources
cp Info.plist build/DoNotSleep.app/Contents/Info.plist
xcrun swiftc \
-sdk "$(xcrun --show-sdk-path --sdk macosx)" \
-target "$(uname -m)-apple-macos$(sw_vers -productVersion | awk -F. '{print $1 "." $2}')" \
DoNotSleep.swift \
-o build/DoNotSleep.app/Contents/MacOS/DoNotSleep
open build/DoNotSleep.app- Left click the status bar icon to switch between sleep-allowed and do-not-sleep modes.
- Right click the status bar icon to open the menu.
- Choose
Quitto stop the app and release the activecaffeinateprocess.
DoNotSleep.swift: app entry point and tray logic.GenerateIcon.swift: vector-style icon generator used during bundle build.Info.plist: app bundle metadata for macOS.build_app.sh: app bundle build helper.codesign_app.sh: local signing helper for a built.app.package_release.sh: zip packaging helper for GitHub Releases.launch.sh: build-and-run helper for local usage..github/workflows/build-release.yml: GitHub Actions workflow that builds the app and uploads release artifacts.
- The repository is Swift-only; the previous Python implementation has been removed.
build/DoNotSleep.appis the distributable local artifact.dist/*.zipis the upload-ready artifact for GitHub Releases.- Build outputs and logs are ignored via
.gitignore. - Before publishing, run
./package_release.shand verify that the generated zip expands and launches on macOS.