{"id":50677125,"url":"https://github.com/stickerdaniel/sleep-preventer","last_synced_at":"2026-06-08T16:05:25.871Z","repository":{"id":359207259,"uuid":"1245020372","full_name":"stickerdaniel/sleep-preventer","owner":"stickerdaniel","description":"Tiny macOS menubar app: keep your Mac awake for a fixed time (closed lid stays alive), then sleep normally.","archived":false,"fork":false,"pushed_at":"2026-05-20T20:57:18.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-21T02:36:30.780Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stickerdaniel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-20T20:40:16.000Z","updated_at":"2026-05-20T20:57:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stickerdaniel/sleep-preventer","commit_stats":null,"previous_names":["stickerdaniel/sleep-preventer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/stickerdaniel/sleep-preventer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stickerdaniel%2Fsleep-preventer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stickerdaniel%2Fsleep-preventer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stickerdaniel%2Fsleep-preventer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stickerdaniel%2Fsleep-preventer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stickerdaniel","download_url":"https://codeload.github.com/stickerdaniel/sleep-preventer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stickerdaniel%2Fsleep-preventer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34069516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-08T16:05:25.101Z","updated_at":"2026-06-08T16:05:25.866Z","avatar_url":"https://github.com/stickerdaniel.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sleep Preventer\n\nA tiny macOS menubar app that keeps your Mac awake for a fixed amount of time, then lets it sleep normally. While active, closing the lid does not put the Mac to sleep — useful when an AI agent or long-running task needs to keep working on your laptop while you carry it.\n\n| Feature | Detail |\n|---|---|\n| Manual timer | Click \"+15 min\" to add 15 minutes; click \"Stop\" to cancel. |\n| Closed lid, awake system | Lid close → backlight off (zero display battery), but the system stays awake. |\n| Auto-sleep on expiry | Timer reaches zero → normal sleep is re-enabled; if the lid is closed, the Mac sleeps immediately. |\n| Battery-friendly | No always-on background loop. Sleep prevention only runs while the timer is active. |\n| Crash-safe | LaunchAgent restarts on non-zero exit. Boot reconciliation clears any leaked `disablesleep=1`. |\n\n## Install\n\n```bash\ngit clone https://github.com/stickerdaniel/sleep-preventer.git\ncd sleep-preventer\n./scripts/install.sh\n```\n\nClone anywhere you like — the installer builds in `.build/` next to the source and copies the binary to `/usr/local/bin/`, so the source directory location doesn't matter.\n\nThe installer will:\n\n1. Build the release binary with `swift build -c release`.\n2. Copy it to `/usr/local/bin/sleep-preventer` (asks for sudo).\n3. Install a scoped passwordless sudoers rule at `/etc/sudoers.d/sleep-preventer` allowing only `pmset -a disablesleep *` and `pmset sleepnow`.\n4. Drop a LaunchAgent at `~/Library/LaunchAgents/com.sleep-preventer.plist` and start it via `launchctl bootstrap` + `kickstart`.\n\nAfter install, look for a `bolt.slash` icon in your menubar.\n\n## Usage\n\n| Click | Effect |\n|---|---|\n| `+ 15 min` (idle) | Starts a 15-minute timer. Icon becomes `bolt.fill`. System sleep is disabled. |\n| `+ 15 min` (running) | Adds 15 minutes to the remaining time. |\n| `Stop` | Cancels the timer. If the lid is closed, the Mac sleeps immediately. |\n| `Quit` | Exits the app cleanly. Sleep is re-enabled. The LaunchAgent does **not** auto-restart after a clean Quit (`KeepAlive: {SuccessfulExit: false}`). |\n\n## How it works\n\n- `pmset -a disablesleep 1` (via sudoers) prevents both lid-close and idle sleep.\n- A polled `ioreg AppleClamshellState` check detects lid open/close and calls `pmset displaysleepnow` on close to kill the backlight while the system stays awake.\n- On timer expiry or Stop, `pmset -a disablesleep 0` re-enables sleep. If the lid is closed at that moment, `pmset sleepnow` puts the Mac to sleep immediately.\n\n## Requirements\n\n- macOS 14 (Sonoma) or later\n- Swift 5.9+\n- Admin password (one time, during install) for the sudoers rule\n\n## Uninstall\n\n```bash\nlaunchctl bootout \"gui/$(id -u)/com.sleep-preventer\" 2\u003e/dev/null || true\nrm -f ~/Library/LaunchAgents/com.sleep-preventer.plist\nsudo rm -f /usr/local/bin/sleep-preventer\nsudo rm -f /etc/sudoers.d/sleep-preventer\nsudo pmset -a disablesleep 0\n```\n\n## Predecessor\n\nSleep Preventer replaces [opencode-sleep-control](https://github.com/stickerdaniel/opencode-sleep-control), which was driven by an HTTP `/active`/`/idle` plugin model intended for OpenCode. The new app trades that for a simpler manual timer UI — no daemon dependency on an external editor.\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstickerdaniel%2Fsleep-preventer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstickerdaniel%2Fsleep-preventer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstickerdaniel%2Fsleep-preventer/lists"}