Skip to content

biyachuev/DoNotSleep

Repository files navigation

DoNotSleep

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.

Features

  • Left click on the tray icon toggles Do Not Sleep on 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 .icns app icon.
  • Quitting the app cleanly stops the running caffeinate process.

Requirements

  • macOS
  • Xcode Command Line Tools or Xcode with xcrun swiftc

Install the command line tools if needed:

xcode-select --install

Build App Bundle

Create a macOS app bundle in build/DoNotSleep.app:

./build_app.sh

The generated bundle contains:

  • build/DoNotSleep.app/Contents/Info.plist
  • build/DoNotSleep.app/Contents/MacOS/DoNotSleep
  • build/DoNotSleep.app/Contents/Resources/DoNotSleep.icns

You can launch it from Finder, with open, or with the helper script below.

Run

Start the app with the helper script:

./launch.sh

The script builds build/DoNotSleep.app when needed and launches the bundled app in the background.

Package A Release

Build a versioned zip in dist/ for GitHub Releases:

./package_release.sh

This produces:

  • dist/DoNotSleep-<version>-macos.zip
  • dist/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.

Code Signing

Sign the app bundle locally with a Developer ID certificate:

SIGN_IDENTITY="Developer ID Application: Your Name (TEAMID)" ./codesign_app.sh

Or sign while packaging the release zip:

SIGN_IDENTITY="Developer ID Application: Your Name (TEAMID)" ./package_release.sh

The signing script runs:

  • codesign --force --deep --options runtime
  • codesign --verify
  • spctl --assess

Build Manually

./build_app.sh
open build/DoNotSleep.app

Build Without Helper Scripts

mkdir -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

Behavior

  • 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 Quit to stop the app and release the active caffeinate process.

Repository Layout

  • 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.

Publishing Notes

  • The repository is Swift-only; the previous Python implementation has been removed.
  • build/DoNotSleep.app is the distributable local artifact.
  • dist/*.zip is the upload-ready artifact for GitHub Releases.
  • Build outputs and logs are ignored via .gitignore.
  • Before publishing, run ./package_release.sh and verify that the generated zip expands and launches on macOS.

About

Minimal macOS menu bar app that prevents sleep via caffeinate

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors