Step 1
Installation
There are two ways to get Coffeetosh. Download the Mac app directly and enable CLI access from inside the app, or install via Homebrew if you prefer terminal-first setup.
.dmg from GitHub Releases or via Homebrew. Requires macOS 13 Ventura or later.$ brew install coffeetosh
/usr/local/bin/coffeetosh. You can also run it from the terminal directly:$ coffeetosh install-cli
coffeetosh status to confirm the CLI is installed correctly.$ coffeetosh status
Coffeetosh: INACTIVE
Core Concept
Two Operating Modes
Coffeetosh has two modes for preventing sleep. Choose based on your use case.
pmset to disable sleep assertions at the kernel level.IOPMAssertion — no sudo required.--low-power to any Lid Closed session to simultaneously enable macOS Low Power Mode. It's automatically restored when the session ends.
Under the Hood
How Lid Closed Mode Works
Most apps that prevent sleep only work while the lid is open. Coffeetosh is different — it keeps your Mac fully operational with the lid physically shut, SSH sessions alive, and an automatic password lock when the lid is opened again. Here is exactly what happens at every step.
coffeetosh start coffeetosh-daemon (detached)
| |
|-- sudo pmset -a disablesleep 1 |
| (admin password, once) |
|-- spawn daemon ──────────────────> | caffeinate -is (holds sleep prevention)
|-- write status.json | IOKit lid poll (every 5 seconds)
`-- exit |
|
----------- lid closes ------------- |
|-- save brightness to status.json
|-- set display to minimum
`-- Mac keeps running (SSH, processes...)
----------- lid opens -------------- |
|-- CGSession -suspend
`-- macOS password lock screen (OS-level)
-- stop / timer / SIGTERM ---------- |
|-- restore pmset (admin password, once)
|-- kill caffeinate
|-- restore brightness
`-- exit
coffeetosh startpmset -a disablesleep 1sudo. This runs pmset -a disablesleep 1, which tells the macOS power management kernel extension to ignore all sleep assertions — including the clamshell (lid) sensor. No kernel extensions, no SIP bypass, no credentials stored. The original pmset settings are captured first so they can be restored exactly on stop.# Set at start (requires admin password once):
pmset -a disablesleep 1
# Restored at stop (requires admin password once):
pmset -a disablesleep 0
coffeetosh-daemon — as a fully detached background process. The daemon is orphaned from the CLI immediately and survives terminal closes, SSH disconnects, and parent app quits. The CLI writes ~/.coffeetosh/status.json with the session metadata (mode, duration, start time, PID), then exits. From this point the daemon owns everything.caffeinate -iscaffeinate -is as a child subprocess. -i prevents idle sleep, -s prevents system sleep. Combined with the pmset flag set in Step 2, macOS cannot sleep regardless of lid state. The caffeinate PID is also written to status.json so it can be targeted for cleanup if the daemon exits unexpectedly.AppleClamshellState property from IOPMrootDomain via IOKit on a 5-second tick loop. This is the same low-level registry value that macOS itself reads to detect lid transitions — no third-party drivers, no private APIs. The daemon also watches status.json for an external stop signal (from coffeetosh stop or the menu bar app).status.json as a restore target. It then sets the built-in display to minimum brightness. The Mac continues running normally — SSH sessions stay alive, processes keep running, the internal display is simply dark. The clamshell state does not interrupt any work.CGSession -suspend. This is the OS-level screen lock — identical to pressing Ctrl+Cmd+Q. macOS requires your login password before the desktop is accessible. This lock is owned by securityd and the WindowServer Aqua session layer — killing Coffeetosh does not affect it. The daemon also restores the display brightness to the value saved at lid-close.coffeetosh stop is run, or when the daemon receives SIGINT / SIGTERM / SIGHUP, it runs the same teardown: restores pmset to the exact snapshot captured at start (requires admin password once), terminates the caffeinate subprocess, restores the saved display brightness, and marks the session inactive in status.json. Your Mac returns to its normal sleep behaviour.pmset -a disablesleep 1) and once at stop (to restore it). The password is never stored. It is piped to sudo -S via stdin with terminal echo disabled and the pipe is closed immediately. If your sudo auth token is still valid, no prompt appears at all.
CGSession -suspend calls into the macOS Security Server and WindowServer. It is the same code path as the system Ctrl+Cmd+Q keyboard shortcut and cannot be circumvented by stopping or killing Coffeetosh. If Coffeetosh is force-quit before the lid fires, the lid opens normally — no security degradation, simply no auto-lock.
CLI Reference
All Commands
Every command available via the coffeetosh CLI. Arguments in [brackets] are optional.
$ coffeetosh start # Use saved Quick Preset
$ coffeetosh start 8 # Lid Closed, 8 hours
$ coffeetosh start 2 --mode keep-awake # Keep Awake, 2 hours
$ coffeetosh start 8 --low-power # Lid Closed + Low Power Mode
$ coffeetosh start 0 # Start indefinitely
$ coffeetosh start --minutes 90 # Lid Closed, 90 minutes
$ coffeetosh start -m 45 # Shorthand for --minutes
| Flag | Default | Description |
|---|---|---|
| [hours] | 8 | Session duration in hours. Use 0 for indefinite. |
| --mode <mode> | coffeetosh | coffeetosh / lid-closed or keep-awake / a or b |
| --low-power | off | Enable macOS Low Power Mode for the session (Lid Closed only). Auto-restores on stop. |
| --minutes / -m | — | Specify duration in minutes instead of hours. E.g. -m 90 |
$ coffeetosh stop
stop will prompt for your admin password once to restore pmset settings.
$ coffeetosh status
Coffeetosh: ACTIVE (Mode: Lid Closed)
Started: 2025-01-15 22:10:04
Duration: 8h | Remaining: 6h 42m
Daemon PID: 4821 (running)
Lid: Closed 🔒
$ coffeetosh add # Add 30 minutes (default)
$ coffeetosh add 60 # Add 60 minutes
$ coffeetosh add 1.5 # Add 1.5 hours (90 minutes)
coffeetosh start with no arguments immediately applies it. Syncs with the app's Settings panel.$ coffeetosh preset # Show current preset
$ coffeetosh preset set keep-awake 2h # Save: Keep Awake, 2h
$ coffeetosh preset set lid-closed 8h # Save: Lid Closed, 8h
$ coffeetosh preset set lid-closed 0 # Save: Lid Closed, indefinite
$ coffeetosh preset set keep-awake 30m # Save: Keep Awake, 30 min
$ coffeetosh preset clear # Remove saved preset
| Duration format | Example |
|---|---|
| Hours | 2h, 8h, 24h |
| Minutes | 30m, 90m |
| Indefinite | 0 or inf |
pmset.$ coffeetosh battery
Battery: 79% — discharging
Source: Battery Power
Time: 3:42 remaining
powermetrics to sample SMC sensors and display CPU die and GPU die temperatures. Requires admin password once per invocation. Alias: temp.$ coffeetosh mac-temp
Mac temperature (admin password may be required):
CPU die temperature: 48.32 C
GPU die temperature: 41.85 C
powermetrics — no third-party sensors or kernel extensions needed.
/usr/local/bin/coffeetosh pointing to the binary bundled inside the .app. After this, you can run coffeetosh from any terminal session.$ coffeetosh install-cli
coffeetosh installed at /usr/local/bin/coffeetosh
Run: coffeetosh status
$ coffeetosh help
$ coffeetosh --help
$ coffeetosh -h
Workflow Tip
Using Quick Preset
Quick Preset lets you save your most-used session so that a single coffeetosh start command kicks it off instantly — no flags required. Set it once, and it's available in both the CLI and the menu bar app.
# 1. Save your preset once
$ coffeetosh preset set lid-closed 8h
Quick Preset saved: Lid Closed - 480m
coffeetosh start ← will now use this preset
# 2. From now on, just run:
$ coffeetosh start
Quick Preset: Lid Closed - 480m
☕ Coffeetosh started!
Mode: Lid Closed
Duration: 8h
Daemon PID: 5204
Advanced
Remote & SSH Use
Because Coffeetosh runs as a daemon, you can start sessions remotely from another machine over SSH. The daemon stays alive even after you close the SSH connection.
# Start a 12-hour Lid Closed session on a remote Mac
$ ssh user@macbook.local "coffeetosh start 12"
# Check session status remotely
$ ssh user@macbook.local "coffeetosh status"
# Stop remotely
$ ssh user@macbook.local "coffeetosh stop"
keep-awake mode, which requires no sudo.
Help
Troubleshooting
command not found: coffeetosh
coffeetosh install-cli once you can locate the binary inside the app bundle.
Admin password prompt on every start
--mode coffeetosh) requires pmset -a disablesleep 1, which is an admin-level pmset change. macOS prompts for your password because this modifies a system-level power setting. Keep Awake mode (--mode keep-awake) never prompts for a password.
Session shows INACTIVE right after start
coffeetosh status again. If it still shows inactive, check that the Coffeetosh app is installed in /Applications (the daemon binary is embedded inside it).
Mac woke up even with Coffeetosh active
coffeetosh stop says "not active" after a crash
coffeetosh stop to force-restore pmset settings. If the session file is stale, you can also manually reset with: sudo pmset -a disablesleep 0 to ensure sleep is re-enabled.
How do I uninstall Coffeetosh?
coffeetosh stop. Then remove the app from /Applications. To remove the CLI symlink: sudo rm /usr/local/bin/coffeetosh. All preferences are stored in ~/Library/Application Support/Coffeetosh/ which you can also delete.