One line and this Mac does not sleep — lid open or closed — until you hit Ctrl-C.
$ snort
ID please (sudo). the good stuff is behind the counter.
Password:
oooooh yeah, that's the good stuff...
(o_O) wired for 04:12:37
Asks for your password once, then holds the machine awake and prints a running timer. Ctrl-C (or closing the terminal window) sobers it up and puts everything back.
^C
aaand it's gone. comedown initiated.
| setting | while running | on exit |
|---|---|---|
disablesleep |
1 — lid close no longer sleeps the machine |
back to whatever it was (normally 0) |
caffeinate -ims |
running as a child process | killed |
displaysleep |
untouched by default — the screen still turns off on its normal timer, the Mac keeps running. snort bright sets it to 0 and uses caffeinate -dimsu instead |
back to the per-source values it read at launch |
The greeting and the comedown line are picked at random from a small stash in
the script — add your own to the hits / comedowns arrays up top.
Originals are read from pmset at launch rather than hardcoded, so changing
your Energy Saver prefs later doesn't break the restore.
Sudo credentials are kept warm in a background loop. Without that, Ctrl-C after a few hours would stall on a password prompt at exactly the wrong moment.
Traps INT, TERM, HUP and EXIT — so closing the terminal cleans up too.
./install.sh
Symlinks /usr/local/bin/snort here, so edits to this file take effect
immediately with no re-copy.
-
The built-in screen is physically dark with the lid shut. Nothing can change that. The Mac stays awake and running; you just can't see it without an external display.
-
Heat and battery. A closed laptop has no airflow, and with sleep disabled it will snort the whole battery down to 0% and faceplant rather than sleeping. It warns you if you start on battery. Stay on AC for long sessions.
-
A hard kill (
kill -9, power loss, panic) skips the trap — no comedown, and the settings stay applied. Sober it up by hand:sudo pmset -a disablesleep 0 && sudo pmset -b displaysleep 2 && sudo pmset -c displaysleep 10
Unplugged and at or below 5% (SNORT_MIN_BATT to change it), snort sobers
up on its own and exits. The Mac then sleeps normally instead of running flat
and hard-powering-off with the settings still snorted.
5% left. that's the bottom of the bag. we're done here.
crashing hard. the machine may dream once more.
The originals are written to ~/.local/state/snort/originals before anything
is changed. That file is the source of truth for the comedown, not whatever
pmset happens to say later.
- Died mid-trip (
kill -9, crash, reboot, terminal force-quit)? The nextsnortnotices the stale state file, restores from it first, and only then reads fresh originals. Or runsnort soberto restore without re-dosing. - Ran it twice? The second one sees a live snort in the state file, says so, and exits 0. Nothing gets double-set, so the originals can't be overwritten with snorted values.
- No state file but the settings already look snorted (
disablesleep=1,displaysleep=0on both sources)? It refuses to "preserve" that and will restore macOS defaults (0,2,10) on comedown instead.
$ snort status
disablesleep=0 displaysleep: battery=2 ac=10
not wired. no state file.
$ snort sober
nothing to sober up from. you're clean.
- Improve the voice lines. More of them, funnier, less repetition.