@tejasybhakta: leaking some solo-founder alpha: I run a lot of agents. every time I close my laptop to take it with me, I literally sh…
Summary
A shell script that wraps macOS's caffeinate command to keep the laptop awake when the lid is closed, allowing agents to continue running without interruption.
View Cached Full Text
Cached at: 08/24/26, 07:55 AM
leaking some solo-founder alpha:
I run a lot of agents. every time I close my laptop to take it with me, I literally shut down the company.
wrap macOS’s native caffeinate so now it
- connects to my phone’s hotspot
- keeps it awake while closed so agents keep running
ctrl-cexits and restores normal sleep.
curl -fsSL https://gist.githubusercontent.com/bhaktatejas922/da5965539a05106114416b3bc61c1197/raw/caffeinate-lid.zsh… >> ~/.zshrc && exec zsh
will leak more alpha soon
Source: https://gist.githubusercontent.com/bhaktatejas922/da5965539a05106114416b3bc61c1197/raw/caffeinate-lid.zsh # ============================================================================ # CAFFEINATE — hold the lid open too # ============================================================================ # `caffeinate -d` keeps the display awake, but macOS still sleeps the machine # when the lid closes. This wrapper pairs -d with `pmset disablesleep 1` for # exactly the lifetime of the caffeinate process and puts the previous value # back on the way out: normal exit, Ctrl-C, SIGTERM, or the shell going away. # Holders are reference counted, so concurrent caffeinates are safe and the # last one out restores — the lid setting AND the wi-fi network the hotspot # join displaced (hotspot_leave). Needs passwordless sudo for /usr/bin/pmset. CAFFEINATE_LID_DIR=“\{TMPDIR:\-/tmp\}/caffeinate\-lid\.UID” CAFFEINATE_LID_APP=“HOME/Library/Application Support/CaffeinateLid/CaffeinateLid\.app" \# Menu\-bar indicator\. It reads the holder directory itself and quits once the \# last holder is gone, so there is nothing to tear down on the way out\. \`open\` \# on an already\-running app is a no\-op activation, which keeps it a singleton\. \# Source \+ build script: ~/\.config/caffeinate\-lid\. \_caffeinate\_lid\_indicator\(\) \{ \[\[ \-d "CAFFEINATE_LID_APP” ]] || return 0 open -g -a “CAFFEINATE\_LID\_APP" \-\-args "CAFFEINATE_LID_DIR” 2>/dev/null } _caffeinate_lid_lock() { local i for i in {1..50}; do mkdir “CAFFEINATE\_LID\_DIR/lock" 2\>/dev/null && return 0 sleep 0\.1 done return 1 \} \_caffeinate\_lid\_unlock\(\) \{ rmdir "CAFFEINATE_LID_DIR/lock” 2>/dev/null } # Holder files are named holder..; drop any whose shell died. _caffeinate_lid_reap() { local f pid for f in “CAFFEINATE\_LID\_DIR"/holder\.\*\(N\); do pid="{\{{f:t}#holder.}%%.*}” kill -0 “pid" 2\>/dev/null \|\| rm \-f "f” done } # Caller must hold the lock. Restores the saved setting once nobody holds it. _caffeinate_lid_restore_if_idle() { _caffeinate_lid_reap local -a holders=(“$CAFFEINATE_LID_DIR”/holder.*(N)) (( \{\#holders\} \)\) && return 0 local prior=0 \[\[ \-r "CAFFEINATE_LID_DIR/prior“ ]] && prior=“\(<"CAFFEINATE_LID_DIR/prior”)“ sudo -n pmset -a disablesleep “\{prior:\-0\}" rm \-f "CAFFEINATE_LID_DIR/prior” # Travel over: hand wi-fi back from the hotspot to the network it # displaced (hotspot.zsh). A no-op when the join never happened. (( \+functions\[hotspot\_leave\] \)\) && hotspot\_leave \} \_caffeinate\_lid\_acquire\(\) \{ local token="1“ mkdir -p “CAFFEINATE\_LID\_DIR" \|\| return 1 \_caffeinate\_lid\_lock \|\| return 1 \_caffeinate\_lid\_reap local \-a holders=\("CAFFEINATE_LID_DIR”/holder.*(N)) if (( ${#holders} == 0 )); then pmset -g | awk ’/SleepDisabled/{print 2\}' \> "CAFFEINATE_LID_DIR/prior“ if ! sudo -n pmset -a disablesleep 1; then rm -f “CAFFEINATE\_LID\_DIR/prior" \_caffeinate\_lid\_unlock return 1 fi fi : \> "CAFFEINATE_LID_DIR/holder.token" \_caffeinate\_lid\_indicator \_caffeinate\_lid\_unlock \} \_caffeinate\_lid\_release\(\) \{ local token="1” [[ -e “CAFFEINATE\_LID\_DIR/holder\.token” ]] || return 0 # already released _caffeinate_lid_lock || return 1 rm -f “CAFFEINATE\_LID\_DIR/holder\.token” _caffeinate_lid_restore_if_idle _caffeinate_lid_unlock rmdir “CAFFEINATE\_LID\_DIR" 2\>/dev/null return 0 \} \# Shell going away \(exit, SIGHUP, closed window\): drop the holders it owns\. \_caffeinate\_lid\_atexit\(\) \{ \[\[ \-d "CAFFEINATE_LID_DIR” ]] || return 0 local f for f in “CAFFEINATE\_LID\_DIR"/holder\.\.\*\(N\); do \_caffeinate\_lid\_release "{\{f:t\}\#holder\.\}" done \} \# Safety net for a SIGKILLed shell: the next prompt in any shell notices that \# every holder is dead and restores sleep\. One stat in the common case\. \_caffeinate\_lid\_sweep\(\) \{ \[\[ \-d "CAFFEINATE_LID_DIR” ]] || return 0 local -a holders=(“$CAFFEINATE_LID_DIR”/holder.*(N)) (( ${#holders} )) || return 0 local f for f in holders; do kill \-0 "{\{{f:t}#holder.}%%.*}“ 2>/dev/null && return 0 done _caffeinate_lid_lock || return 0 _caffeinate_lid_restore_if_idle _caffeinate_lid_unlock rmdir “CAFFEINATE\_LID\_DIR" 2\>/dev/null \} caffeinate\(\) \{ local arg lid=0 for arg in "@”; do [[ $arg == -- ]] && break [[ arg == \-\*d\* \]\] && \{ lid=1; break \} done \(\( lid \)\) \|\| \{ command caffeinate "@“; return } local token=”$\.RANDOMRANDOM" if \! \_caffeinate\_lid\_acquire "token“; then print -u2 “caffeinate: could not disable lid sleep; continuing without it” hotspot || print -u2 “caffeinate: hotspot join failed; continuing on current network” { command caffeinate “$@” } always { (( \+functions\[hotspot\_leave\] \)\) && hotspot\_leave \} return fi print \-u2 "caffeinate: lid sleep disabled — restores when this exits" \# Awake\-hold first, then travel: join the hotspot only after sleep is \# pinned, so a slow Instant Hotspot join can't race the lid closing\. \# Best\-effort — a missing hotspot never blocks the caffeinate itself\. hotspot \|\| print \-u2 "caffeinate: hotspot join failed; continuing on current network" \{ command caffeinate "@“ } always { _caffeinate_lid_release “$token” } } autoload -Uz add-zsh-hook add-zsh-hook zshexit _caffeinate_lid_atexit add-zsh-hook precmd _caffeinate_lid_sweep
Tejas Bhakta (@tejasybhakta): the one-man inference provider i hit a $6m run rate as a solo dev morph was 1 person until last week
the first inference provider to be live with kimi k3 without early weights access 250 customer slack connect channels i could’ve made morph a 1-person $1b company, but it
Similar Articles
Show HN: Adrafinil – keep a lid-closed Mac awake only while agents work
Adrafinil is a macOS tool that keeps the system awake only while AI agents are active, preventing sleep during agent sessions while allowing normal sleep otherwise.
@gabriel1: "your backpack is open" yes im running 100 agents by sharing internet from my phone to the macbook max in my backpack, …
A user shares that they are running 100 AI agents by tethering internet from their phone to a MacBook Max in their backpack, expressing concerns about overheating.
Ajar
Ajar is a Mac utility that provides lid angle sync and keep awake functionality for AI agents.
Capsomnia
Capsomnia is a utility that keeps your Mac awake when the lid is closed by using the Caps Lock key.
@ishaansehgal: Your agents die when you close your laptop. We fixed that. Omnara Cloud Sandboxing is live. Close your laptop, the sess…
Omnara Cloud Sandboxing allows users to close their laptop without killing their agents, as sessions continue running in the cloud and resume seamlessly.