tom
tom

Reputation: 2299

Is it possible from javascript/browser to prevent OS X from sleeping?

Is it possible from javascript in the browser to prevent OS X from sleeping?

I'm writing a library for uploading large files, and we're finding that the default power settings in Mountain Lion (sleep after 15 minutes, when plugged in) are causing issues. The uploads are paused while the OS sleeps. They resume upon wake, but its making the uploads much slower for anyone who leaves their Mac to sit.

If there is no official API for this, are there any hacks? Play a silent 1px x 1px video on loop?

thanks

tom

Upvotes: 1

Views: 1163

Answers (1)

Adi
Adi

Reputation: 1273

One approach that works is to play a video in the background. You can adapt this project's sleep.js file to suit your needs:

https://github.com/ivanmaeder/computer-sleep

Tested with Chrome.

Upvotes: 3

Related Questions