Show HN: Prevent your computer sleeping with just a webpage (nosleep.page)
There's often times I want to prevent a computer/laptop/VM from sleeping and while, yes, there's various Caffeine/Amphetamine apps they're often overkill.
Instead, this small (12Kb) page does the job and only needs a web browser.
It's just a very simple usage of a web api normally used for things like video players: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake...
136 comments
[ 2.2 ms ] story [ 149 ms ] threadFrom my testing, it works even if the window is in the background somewhere but generally it stops working if you switch to a different tab within the same window.
You should get a popup though if you do something that causes the page to lose its Wake Lock (which works by listening to the release event: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake...)
This library implements a hack and plays a very tiny video in a loop too. This should even work on mobile devices and (according to my personal&tiny tests) is not that inefficient as it sounds :)
powercfg.exe -x -monitor-timeout-ac 5 powercfg.exe -x -disk-timeout-ac 180 powercfg.exe -x -standby-timeout-ac 180 powercfg.exe -x -hibernate-timeout-ac 999
`
Disclaimer: I built the tool.
I've seen it on some recipe websites recently and was wondering how it worked.
I would recommend making the links (eg to the Mozilla page) use a different color or underlined.
[0] https://bulma.io/documentation/helpers/color-helpers/
I didn’t even know this was a feature of my browser. Say for example I write a shopping list based on the recipe web page, then go to the supermarket to buy the ingredients, leaving the tab open because I will need the instructions tomorrow for the cooking. Now my computer will be forced on during the rest of day based on the choice of the website owner?! Wtf. What if I leave the tablet open after finishing cooking, Is there any timeout on this thing or will that differ depending on each website?
Honestly this feature is really badly thought through. It should be a feature of the OS and not up to random web sites without even asking for permission.
Putting my most cynical hat on you could imagine advertisers enabling this on every website so you are more likely to be exposed to their ads.
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.
I do a `caffeinate -d` and then throw my mouse to a hot corner to activate the screen saver.
I think you buried the lede there...
https://www.ifixit.com/Wiki/What_to_do_with_a_swollen_batter...
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.
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.
You can tell caffeinate to watch for other processes too, to make sure a browser thread doing a download will finished uninterrupted before sleeping.
However, the GREEN background is very annoying. I don't need the whole webpage to be green for me to know it's on and working. I can't minimize the browser (firefox) because then it apparently doesn't work. So I'm left with a very big green screen sitting in the corner of my eye. Wondering too the effect of that in terms of screen color burnout (if that's even a thing anymore).
I would definitely recommend to tone down the color scheme. Stay away from green. Just go with grey and darker grey or black for your on/off schemes, including inside of the slider button.
My use case is that I have the "nosleep" computer on the side of my desk. It catches IM/chat messages (from Teams, etc.) and email (from Outlook). I don't like my primary development machine bothered by these notifications, but I do like having that machine "awake" and alert to chat/email notifications (and I can't (or shouldn't) change the default policies on that machine).
Can't you have a separate, tiny window?
Lots of ways to attack that, host it yourself, change it with chrome dev tools, a bookmarklet that alters the css, user scripts for css overrides like greasemonkey popularized back in the early days of the web. Hope this helps you get the color you'd like :)
Yes, I can probably self-host something like this, change the color schema in a myriad of ways. But I thought the point of Show HN was to showcase and somewhat solicit feedback from the HN community.
I wonder if that page would even work, his work PC at the time (late 2015) was a dual-socket Pentium III which ran surprisingly OK given the already 15+ years of age, but lacked in software support as apps like Skype and Chrome at one point started shipping binaries that required.. SSE2
[0] https://www.dell.com/community/XPS/FAQ-Modern-Standby/td-p/7...
Previous HN discussion: https://news.ycombinator.com/item?id=28639952
Hibernate S4 itself is fine, except the risk of physically triggering wakeup.
I'm not sure about linux or Mac though
Has helped me identify flaky input peripherals or timers many times. Worst was an HP laptop with a wonky touch bar for media controls, that would frequently ghost press and wake the computer, even when in hibernate and with the lid closed.
Ended up being a security risk at our company because someone in marketing didn’t know this and made a full screen video. Well, cleaning staff came in and almost all our PCs were on because lots of people use the company website.
Fixed that nonsense right away.
https://chrome.google.com/webstore/detail/keep-awake/bijihla...
https://nosleep.page
Also, I assume this is a pet project of the author. They had a need, and found a way to solve it. They probably had fun, and learned some things along the way. Often, that’s kind of the whole point of a weekend project.
Even if there is another established solution, ‘Why not just … some other thing’ isn’t great feedback. Discovering people’s ideas and projects is one of the beautiful things about HN.
This is a perfect example. I didn’t even know the Screen Wake Lock API existed, so I learned something new!
You do you though
I was just going off the docs which specifically mention Chrome OS and Chrome-books. Personally, I’ve never really had a use case for something like this.
My only point is, I still applaud the author’s effort here, and it taught me something new about Web APIs. It’s interesting that you can do that at all with a web page!
That seems huge for the task.
https://developer.mozilla.org/en-US/docs/Web/API/Window/befo...
[0]: https://apps.apple.com/us/app/amphetamine/id937984704?mt=12
Edit: I see now that Amphetamine has the option of a similar-looking icon to make it more obvious whether it is enabled or not
[0] https://github.com/newmarcel/KeepingYouAwake
(My first HN comment, via Orion Browser)
Did you manually type that out or is this some “Sent from my iPhone”-esque growth-hacking strategy by the Orion team?
Thanks for working on Orion!
[0] https://github.com/microsoft/PowerToys
Incidentally iTerm will block a restart too, and is useful to have open all the time anyway!
that's a pretty steep cost to pay to simply keep a computer awake because the browser it's using doesn't support a 'stay-awake api'.
edit: Ah, I misunderstood. This is for your highly locked down work computer.
It's a useful feature, I use it to prevent a tablet displaying a dashboard turning off the screen due to lack of user action.
My workstation will certainly not be prevented from entering sleep by anything a webpage can do.
Besides, it's a shame that iOS still doesn't support this API. The video-hack has too many drawbacks and this feature would be very useful for a certain kind of PWAs.
If it's that inconvenient, talk with your IT people and make a case for changing it. If you use stuff like this, I hope you get shitcanned.
I was going to provide a more recent anecdote, but decided against since it was a little too specific.
Uh oh, sounds like you might have to actually do your job too!
All sorts of shit like that happens. People are fundamentally lazy and stupid, which is why we can't have nice things, line workplaces where you don't have to worry about leaving your computer unlocked.
Stuff like this site that makes it easier to embrace the laziness and stupidity just make life worse.
How about no browsers? How about limiting network access to a strict whitelist approved by the boss and nothing else?
That's the type of shit that happens when you create tools like this. I 100% guarantee this site will be misused and the resulting corporate overcorrection will make hundreds or thousands of people's lives objectively worse.