A minimalist macOS menu bar app that prevents your Mac from sleeping, screen locking, and display turning off.
- Prevent System Sleep -- Stops macOS from entering sleep mode via IOKit power assertions
- Prevent Screen Lock -- Keeps the display on and prevents the lock screen
- One-Toggle Design -- A single switch controls both behaviors simultaneously
- Lightweight -- Runs as a menu bar app (no Dock icon), minimal resource usage
- 10 Languages -- Supports Chinese, English, Japanese, Korean, French, German, Spanish, Portuguese, Russian, and Arabic
- Language Auto-Detection -- Automatically detects your system language on first launch
- RTL Support -- Full right-to-left layout support for Arabic
- Zero Dependencies -- Pure Swift + IOKit, no third-party packages required
- One-Click Build -- Double-click
build.commandto compile, sign, and package as DMG
The app lives in the menu bar. Click the moon icon to open the popover panel where you can toggle sleep prevention on/off, switch languages, or quit the app.
- Launch NoSleep -- it appears in your menu bar as a moon icon
- Click the icon to open the control panel
- Toggle the switch ON -- your Mac will stay awake and the screen will remain on
- Toggle OFF -- your Mac returns to normal sleep behavior
- Right-click the menu bar icon for quick access to About and Quit
| Language | Code |
|---|---|
| 简体中文 | zh-Hans |
| English | en |
| 日本語 | ja |
| 한국어 | ko |
| Français | fr |
| Deutsch | de |
| Español | es |
| Português (Brasil) | pt-BR |
| Русский | ru |
| العربية | ar |
- macOS 12.0+ (Monterey or later)
- Xcode Command Line Tools -- install via
xcode-select --install - Swift 5.7+
# Clone the repository
git clone https://github.com/XYRZX/NoSleep.git
cd NoSleep
# One-click build (compile, sign, package DMG)
./build.commandThe script will:
- Generate the app icon from
icon_1024.png - Compile all Swift sources
- Generate
Info.plist - Code-sign the app (auto-detects your signing certificate, falls back to ad-hoc)
- Package as a DMG installer on your Desktop
swiftc -o NoSleep \
-framework Cocoa \
-framework SwiftUI \
-framework IOKit \
-framework Combine \
Sources/NoSleep/*.swiftDownload the latest release from the Releases page.
NoSleep/
├── Sources/
│ └── NoSleep/
│ ├── main.swift # App entry point
│ ├── AppDelegate.swift # Menu bar setup, popover management
│ ├── ContentView.swift # SwiftUI UI (toggle, language selector, quit)
│ ├── SleepPreventer.swift # IOKit power assertion logic
│ └── L10n.swift # Localization (10 languages, inline dictionary)
├── icon_1024.png # App icon source (1024x1024)
├── icon_1024.jpg # App icon JPEG copy
├── Package.swift # Swift Package Manager manifest
├── build.command # One-click build script
└── README.md # This file
NoSleep uses macOS IOKit Power Management assertions (IOPMAssertionCreateWithName):
kIOPMAssertionTypePreventUserIdleSystemSleep-- Prevents the system from entering idle sleepkIOPMAssertionTypePreventUserIdleDisplaySleep-- Prevents the display from turning off
These assertions are automatically released when:
- The user toggles the switch OFF
- The app quits (handled in
applicationWillTerminate)
Instead of traditional .lproj bundles (which require Xcode build settings), NoSleep uses an inline dictionary approach in L10n.swift:
- All translations are embedded as Swift dictionaries at compile time
- No additional resource files or build steps needed
- Language preference is persisted in
UserDefaults - Auto-detects system language on first launch
- Falls back to English for any missing translations
This project is intentionally built with a single swiftc command and a shell script:
- Transparency -- anyone can understand the full build process by reading
build.command - Simplicity -- no
.xcodeproj/.xcworkspacefiles that change with Xcode versions - CI-Friendly -- the build script works identically on local machines and CI servers
- No Lock-In -- doesn't require Xcode (Command Line Tools are sufficient)
Contributions are welcome! Here's how you can help:
- Open
Sources/NoSleep/L10n.swift - Add a new entry to the
supportedLanguagesarray - Add a new dictionary with all keys in
stringsclosure - Add a mapping in
systemLocaleif needed
If you find a bug or have a feature request, please open an issue.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes
- Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
- Built with Swift and SwiftUI
- Uses IOKit Power Management for sleep prevention
- App icon designed with a clean, macOS-native aesthetic