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...
I'm not sure about linux or Mac though
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.
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.
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://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)
https://developer.mozilla.org/en-US/docs/Web/API/Window/befo...
Incidentally iTerm will block a restart too, and is useful to have open all the time anyway!
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.
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 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.
You can tell caffeinate to watch for other processes too, to make sure a browser thread doing a download will finished uninterrupted before sleeping.
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.
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).
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.
From 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...)
Can you explain why? I never wants my Mac to sleep except when I close the lid. Amphetamine does the job; it starts at boot and I don’t have to care about it at all.
Again, web applications are not better for everything, but they are more safe for the average computer user, as they run in a restricted environment, compared to native applications.
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.
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.
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API" style="text-decoration: underline; color: blue;">Screen Wake Lock API</a>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 :)
This tiny site uses the Screen Wake Lock API to prevent your device from sleeping.
Where this API isn't supported, an empty silent video is played to emulate this behaviour (using NoSleep.js).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.
alias decafe='killall caffeinate'
alias cafe='caffeinate -id'
which allows me to just '$ cafe' to keep it awake and '$ decafe' to stop it.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.
My workstation will certainly not be prevented from entering sleep by anything a webpage can do.
https://chrome.google.com/webstore/detail/keep-awake/bijihla...
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
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
`
@echo off
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 999Disclaimer: I built the tool.
That seems huge for the task.