Skip to content

sabraman/sleepoff

Repository files navigation

SleepOff

SleepOff is a small macOS menu bar app for one specific job:

  • keep your Mac awake when the lid is closed
  • force the built-in display brightness to 0 only while the lid is closed
  • restore brightness when the lid opens again

It lives in the menu bar, uses a simple sun / moon state, and avoids repeated password prompts by installing a narrow one-time privilege rule for pmset.

What It Does

  • click the menu bar icon to toggle SleepOff on or off
  • long press the menu bar icon to open a small menu with Change Shortcut… and Quit
  • right click or Option-click also opens the menu
  • adds a global toggle shortcut, defaulting to Control + Command + S
  • prevents sleep with pmset -a disablesleep
  • reads lid state from AppleClamshellState
  • drops brightness to 0 only on lid close
  • restores brightness only when SleepOff actually forced it to 0
  • installs a one-time sudoers rule so future toggles stay quiet

Why It Exists

This started as a tiny shell-command workaround and turned into a menu bar app so the behavior is always one click away.

Install

Homebrew

brew tap sabraman/sleepoff
brew install --cask sleepoff

Upgrade later with:

brew upgrade --cask sleepoff

Nix

There is also a small Darwin-only flake for people who already use Nix:

nix run --extra-experimental-features 'nix-command flakes' github:sabraman/sleepoff

Or build the app bundle output:

nix build --extra-experimental-features 'nix-command flakes' github:sabraman/sleepoff

This is intentionally lightweight and is not being pushed into nixpkgs right now.

Quick Install From GitHub Release

curl -fsSL https://raw.githubusercontent.com/sabraman/sleepoff/main/scripts/install-release.sh | sh

This will:

  • download the latest release zip
  • install SleepOff.app to ~/Applications
  • install the LaunchAgent
  • start the app

Build From Source

./scripts/install.sh

This will:

  • build SleepOff.app
  • copy it to ~/Applications/SleepOff.app
  • install ~/Library/LaunchAgents/local.sleepoff.menubar.plist
  • start the menu bar app

Release Assets

Each GitHub release ships with:

  • .zip Best for Homebrew and scripted installs
  • .dmg Best for manual downloads

The .dmg opens as a drag-to-Applications window.

Password Prompt

macOS requires admin privileges for:

pmset -a disablesleep 1
pmset -a disablesleep 0

SleepOff handles that by installing a one-time sudoers rule limited to those exact commands. After the first approval, later toggles should not keep asking for a password.

Controls

  • click the menu bar icon to toggle SleepOff immediately
  • long press the menu bar icon to open the context menu
  • right click or Option-click also opens the context menu
  • use Control + Command + S to toggle from the keyboard
  • change the shortcut from the long-press menu

Unsigned App

SleepOff is distributed unsigned on purpose.

This project is intentionally lightweight and does not rely on a paid Apple Developer account just to notarize a tiny personal utility.

If macOS blocks the app, see docs/UNSIGNED_APP.md.

Safety Notes

  • closed-lid awake mode can create heat
  • do not use it in a bag
  • do not leave it on soft surfaces like blankets or pillows
  • behavior may vary across macOS versions and MacBook models

How It Works

Main pieces:

Homebrew Tap

Development

Build the app:

./scripts/build.sh

For Nix users:

nix develop --extra-experimental-features 'nix-command flakes'

Build release artifacts:

./scripts/release.sh

That creates:

  • dist/SleepOff-<version>-macos.zip
  • dist/SleepOff-<version>.dmg

About

macOS menu bar app that keeps a MacBook awake with the lid closed and dims the built-in display only while closed

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors