News for hackers. Stuff that matters.
Re:Caffeine-like utility to keep you MacBook awake with its ... by nomel on Friday October 23, 2026 @06:05PM (#50216006)
There are probably 20 of these at this point. I use amphetamine [1] (free on the app store). It has configurable timeouts with optional warnings/notifications, to reduce the ability for your MacBook to melt in your backpack. Can also have it disable when an app closes/download completes/battery percentage, and all sorts of triggers (like bluetooth presence, useful for backpack proximity).

[1] https://apps.apple.com/us/app/amphetamine/id937984704

Re:Caffeine-like utility to keep you MacBook awake with its ... by mathfailure on Friday October 23, 2026 @07:22PM (#50216713)
Are those 20 free and open source as well? Name them then.
Re:Caffeine-like utility to keep you MacBook awake with its ... by nomel on Friday October 23, 2026 @07:30PM (#50216793)
My mistake. Well over 20.

https://www.google.com/search?q=site%3Agithub.com+keep+mac+o...

First one I used was around 9 years ago. Nearly melted my backpack with the hot Intel CPU!

If you don't want to install anything, you can disable sleep with the built in tools: sudo pmset -a disablesleep 1

Re:Caffeine-like utility to keep you MacBook awake with its ... by clash on Friday October 23, 2026 @09:37PM (#50217598)
Yeah, most of these repositories contain more files than caffeinate+ has lines of code.

The API call that 'sudo pmset -a disablesleep 1' does is literally the first thing caffeine+ does. But is only part of the full solution: As soon as the lid closes the command is automatically reverted so you can't forget to do it yourself. Also if you kill caffeinate+, the MacBook is put to sleep when the lid is still closed.

Re:Caffeine-like utility to keep you MacBook awake with its ... by nomel on Friday October 23, 2026 @09:51PM (#50217672)
Yes, most of the very many that you didn't know existed just a moment ago also handle that tricky case of restoring normal operation.
Re:Caffeine-like utility to keep you MacBook awake with its ... by clash on Saturday October 24, 2026 @07:46AM (#50220376)
Bold accusation ;)

You forgot to argue about the LOC vs file count issue.

Also, you are wrong: None does auto sleep on script exit.

Re:Caffeine-like utility to keep you MacBook awake with its ... by nomel on Saturday October 24, 2026 @12:27PM (#50222791)
Oops, didn't follow user names. My mistake.

And, I've been using these for around 9 years. A few I tried most definitely did re-enable on exit. Not sure why file count is a concern, or especially LOC (a truly horrendous metric to target, with the outcome being unintelligible code golf when optimized for). All that I used were exactly one file I was concerned with: a binary or shell script.

This has become strange. Cheers!

Re:Caffeine-like utility to keep you MacBook awake with its ... by clash on Sunday October 25, 2026 @08:10AM (#50230743)
Obviously code-golfed LOC is bullshit. 50 files and GUI for a near-trivial functionality is excessive, though.
Re:Caffeine-like utility to keep you MacBook awake with its ... by randomblock1 on Friday October 23, 2026 @07:34PM (#50216821)
Re:Caffeine-like utility to keep you MacBook awake with its ... by semiquaver on Friday October 23, 2026 @07:41PM (#50216880)
What are you talking about? It’s a one line terminal invocation. These apps are utterly useless. Of course there’s a million open source ones.
Re:Caffeine-like utility to keep you MacBook awake with its ... by clash on Friday October 23, 2026 @09:22PM (#50217532)
Can your one line terminal invocation automatically put the MacBook to sleep when you are connected via ssh and the connection is lost?
Re:Caffeine-like utility to keep you MacBook awake with its ... by nomel on Friday October 23, 2026 @10:00PM (#50217722)
Technically one line ;)

    sudo bash -c 'trap "pmset -a disablesleep 0" EXIT; s=; while :; do if lsof -nP -iTCP:22 -sTCP:ESTABLISHED >/dev/null 2>&1 || pgrep -xq ssh;
  then n=1; else n=0; fi; [ "$n" != "$s" ] && pmset -a disablesleep $n && s=$n; sleep 10; done'
Re:Caffeine-like utility to keep you MacBook awake with its ... by tstrimple on Saturday October 24, 2026 @11:07PM (#50227902)
Switching between headphone output and speaker output on my system is also just one line. I have no idea what that line is because I created a toggle-able icon in waybar which is a really simple script that switches between the two outputs and shows me the correct icon. I didn't need a "tool" to do it, but the packaging and UX are far better than popping up a terminal any time I want to do this.
Re:Caffeine-like utility to keep you MacBook awake with its ... by clash on Friday October 23, 2026 @09:25PM (#50217543)
Yeah, I obviously also did the research prior to implementing my solution.

I did not want GUI, just super simple caffeinate-like CLI. Also I wanted auto-shutdown afterwards.