Live data from Hacker News

Show HN: Prevent your computer sleeping with just a webpage

nosleep.page

51–60 of 137 posts

Re: Show HN: Prevent your computer sleeping with just a webpage

#51
post #33

Earlier quoted context omitted.

> 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 caffeinate` :)

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

Re: Show HN: Prevent your computer sleeping with just a webpage

#52

If you absolutely want to prevent a Mac from not only going to sleep, but restarting for any reason at all (say, to install important security updates, which are usually forced on the user with no choice), there aren't many good ways. The only thing I've found that really works reliably is to open MS Word, create a new document, add some random characters to it, and then leave without ever saving. Word will prevent t…

You can also do this in the browser, using the beforeunload event

https://developer.mozilla.org/en-US/docs/Web/API/Window/befo...

Re: Show HN: Prevent your computer sleeping with just a webpage

#53
post #31

So i get annoyed that my computer doesn't go to sleep sometimes because some website is playing a video. Is there a simple way to tell Linux/Gnome/Chrome to ignore videos and go to sleep anyway? I don't watch long videos on this computer so I hate to come back into my office and find my screen never locked because some website played a video i wasn't even watching.

Firefox (at least in Windows) does allow sleep when there's a no-audio video.

Re: Show HN: Prevent your computer sleeping with just a webpage

#54

If you absolutely want to prevent a Mac from not only going to sleep, but restarting for any reason at all (say, to install important security updates, which are usually forced on the user with no choice), there aren't many good ways. The only thing I've found that really works reliably is to open MS Word, create a new document, add some random characters to it, and then leave without ever saving. Word will prevent t…

Amphetamine[0] works pretty well for me. They also have an extension (a kext, I think) that gives it more reliability. I don't know how reliable it is without that extension though.

[0]: https://apps.apple.com/us/app/amphetamine/id937984704?mt=12

Re: Show HN: Prevent your computer sleeping with just a webpage

#59
post #21

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.

Post reply on HN