explaingit

ddasy/sleepbar

20SwiftAudience · generalComplexity · 1/5LicenseSetup · easy

TLDR

A tiny macOS menu bar app that adds a one-off countdown timer to sleep, lock, or turn off your screen, without permanently changing any system setting.

Mindmap

mindmap
  root((SleepBar))
    What it does
      Countdown timers
      Screen sleep control
      Timed Lock mode
    Timer actions
      Lock screen
      Turn off display
      Full sleep
    Install options
      curl one-liner
      Build from source
      Disk image
    Languages
      English Chinese
      Spanish Arabic
      Japanese German
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Set a 30-minute timer so your Mac screen turns off after a download completes, without changing any system energy settings permanently

USE CASE 2

Enable Timed Lock mode in a shared office so your Mac automatically locks when you walk away for more than 5 minutes, for a set number of hours

USE CASE 3

Keep your screen awake during a presentation with one click, then let normal sleep behavior resume automatically when done

USE CASE 4

Install SleepBar from source with a single curl command and start using it from the menu bar immediately

Tech stack

SwiftmacOS

Getting it running

Difficulty · easy Time to first run · 5min

Requires macOS 14 or later, the pre-built disk image is unsigned so macOS shows a security warning on first launch.

Use freely for any purpose, including commercial, as long as you keep the copyright notice.

In plain English

SleepBar is a small macOS menu bar app that adds a countdown timer for turning off your screen or locking your Mac. The problem it solves is that macOS has a single fixed delay for when the screen turns off, and changing it requires opening System Settings each time. SleepBar puts a clickable icon in your menu bar so you can set a one-off timer of 5, 10, 15, or 30 minutes, one hour, or any custom duration, without changing any system setting permanently. When the countdown ends, you choose what happens: lock the screen only, lock and turn off the display to save power, or put the Mac to sleep entirely. You can also trigger any of those actions immediately with a single click, or flip it to "Never" to keep the screen awake indefinitely for presentations, long downloads, or running scripts. There is also a separate mode called Timed Lock that works differently. Instead of a one-shot countdown, you give it two numbers: how many minutes of no input triggers a lock, and how long the whole thing runs before it stops watching. During that window, the Mac locks itself whenever you walk away for the idle period you chose, then re-arms after you return and unlock. This is useful in shared spaces where you want automatic locking for a couple of hours without permanently changing your system lock settings. The app is built in Swift and described as extremely lightweight, using about zero percent CPU when idle. It wraps macOS command-line tools that are already on your system rather than installing background services or modifying energy settings. All changes are temporary and revert when the timer ends. Installation options include a one-line curl command that compiles and installs the app for you, a manual build from source, or a pre-built disk image from the Releases page. The app is available in English, Chinese, Spanish, Arabic, Portuguese, Japanese, and German. It runs on macOS 14 and later and is released under the MIT license.

Copy-paste prompts

Prompt 1
I want my Mac to lock and turn off the display exactly 20 minutes from now. How do I set a custom timer in SleepBar from the menu bar?
Prompt 2
Explain how to use SleepBar's Timed Lock mode: I want my Mac to lock after 3 minutes of no input, for the next 2 hours, then stop watching automatically.
Prompt 3
How do I install SleepBar using the curl one-liner, and what does the script actually do to my system?
Open on GitHub → Explain another repo

← ddasy on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.