Hacker News new | past | comments | ask | show | jobs | submit login

On macOS just run `caffeinate` from the terminal (or `man caffeinate` for more info on the options).

I know OP copped to “various Caffeine/Amphetamine apps” but said they're often “overkill”. In this case I think a system-provided command is less overkill than a web page that either uses a browser API or plays an empty video.




Does this stay on indefinitely? I don’t like using the command line to enable settings that I only need for an hour or so. I often forget to turn them off.

I like that OP’s site turns keeps my machine awake while it’s open, and I can just close the tab when I want my machine to behave normally.


I regularly use "caffeinate rsync ..." to make sure that syncing finishes before the Macbook is allowed to sleep. So caffeinate just prevents sleeping until rsync terminates.

You can tell caffeinate to watch for other processes too, to make sure a browser thread doing a download will finished uninterrupted before sleeping.


> Does this stay on indefinitely?

If you want. If you don’t, use the `-t` flag for it to turn off after a set number of seconds or `-w` to do so after a specific process ends.


The more unixy way is probably `timeout <seconds> caffeinate` :)


Or `caffeinate sleep <seconds>` which has the (only) added benefit that it comes pre-installed with MacOS


Yes but this got me thinking is it makes more sense to sleep after timing out the caffeination instead of keeping the sleep command running ;) that's enough Unix for the day haha


For some reason caffeinate doesn't keep my computer awake (newish macbook pro)


You might need `caffeinate -d` to prevent the display from sleeping.


While this does work, I agree with OP here. The man page for caffeinate says that it prevents system sleep and, as far as I can tell, it does not do that on my M1 MBP using Monterey.

I do a `caffeinate -d` and then throw my mouse to a hot corner to activate the screen saver.


I've been using a Zoom meeting of just myself, locked, audio and camera off. Worked like a charm when I needed to discharge a swelling battery.


> Worked like a charm when I needed to discharge a swelling battery.

I think you buried the lede there...


It just happens, apparently. Here's a decent rundown:

https://www.ifixit.com/Wiki/What_to_do_with_a_swollen_batter...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: