sindresorhus / project-ideas

Need a JavaScript module or looking for ideas? Welcome ✨
544 stars 9 forks source link

electron-screensaver - native screensavers using electron #40

Open dylang opened 8 years ago

dylang commented 8 years ago

I think it would be fun to be able to easily create native screensavers using web tech like webgl, etc.

https://github.com/atom/electron

After Dark

After Dark

(Screenshots from After Dark, a favorite back in the day.)

RangerMauve commented 8 years ago

What platforms were you thinking? On Windows, screensavers are just exe files that are renamed to .src and go fullscreen when loaded.

dylang commented 8 years ago

Thanks @RangerMauve, I wasn't sure if that was still the case in Windows. What about OS X?

sindresorhus commented 8 years ago

:+1: Want!

I imagine @mattdesl and @hughsk would create some really amazing screensavers with this.

Qix- commented 8 years ago

OSX is a bit different. In /System/Library/Screen Savers, all of your screen savers are in a format similar to .app's, called .saver packages. I'm trying to find a commonality between them and .apps.

In the Contents/MacOS subdirectories of an app and saver, there lives an executable. In app packages, you can just run this directly. This isn't the case with savers.

I ran the following commands to see if maybe they exposed some sort of common public information.

$ file /System/Library/Screen\ Savers/Flurry.saver/Contents/MacOS/Flurry
/System/Library/Screen Savers/Flurry.saver/Contents/MacOS/Flurry: Mach-O 64-bit bundle x86_64

Nothing about screensavers. It just looks like a regular old bundle used by some program.

$ find /System/Library/Screen\ Savers -type d -maxdepth 1 | grep "saver" | xargs -I{} echo "{}/Contents/MacOS" | xargs -I{} find "{}" -type f | xargs -I{} nm "{}" | cut -c18- | grep -E "^T"
T _FastDistance2D
T __LSBindingBadgeMerge
T _destinationSizeForImage
T _iTunesCurrentlyPlayingAlbumName
T _iTunesIsRunning
T _iTunesPause
T _iTunesPlayAlbum
T _iTunesPlayerState
T __randomModuleClass

No common public exports either.

Looks like screensavers are loaded through the ScreenSaverEngine.app package, located in /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app, as plugin bundles.

Some1 articles2 I dug up about the screensaver development cycle.

Qix- commented 8 years ago

@zcbenz / @paulcbetts would this be something worth suggesting as a build option for Electron?

sindresorhus commented 8 years ago

In similarity to https://github.com/atom/electron/issues/2899, I think it might be worth opening a cross-referenced ticket on Electron, for exposure and posterity.

hughsk commented 8 years ago

I've dug into this before, but my native skills are severely limited. Hope somebody can work out how to do this! :grin:

mattdesl commented 8 years ago

This would be neat-o. :+1:

RangerMauve commented 8 years ago

If this was integrated with something like electron-packager then that'd mean we could have cross-platform screensavers which AFAIK isn't a thing that's out there (at least not in a very accessible way)

hughsk commented 8 years ago

Also: while not Electron, I suspect you could get halfway there using CEF.

Qix- commented 8 years ago

@hughsk CEF wouldn't give any advantage over electron other than less bloat. Most platforms that have screensavers use a simple wrapper anyway.

Qix- commented 8 years ago

Also let's all be on the same page here and throw out there that screensavers are merely an aesthetic thing at this point in our technology ;) We don't actually need them anymore.

RangerMauve commented 8 years ago

@Qix- For sure. They're still hella rad, though. :D

forivall commented 8 years ago

Yup, gnome 3 has removed integration of screensavers. (Though they are notorious to remove as many features as possible)

Qix- commented 8 years ago

@RangerMauve I never said they weren't rad :tada:

kevinsawicki commented 8 years ago

/cc @benogle

bengotow commented 8 years ago

Hey folks—noticed this was referenced from https://github.com/atom/electron/issues/2899. To be honest, it seems like overkill to use Electron for this, especially since screensavers are non-interactable. (You move the mouse and it exits). On the Mac, you can already create screensavers with WebKit+JavaScript via https://github.com/tlrobinson/WebSaver and they're quite lean since WebKit is a system framework. Not sure about Win32+Linux, though!

sindresorhus commented 8 years ago

@bengotow Electron is cross-platform and comes with both Node.js and Chromium. Chromium is more up to date tech-wise than WebKit. Node.js has a lot more capabilities than just using the JS bridge and comes with a huge ecosystem of reusable modules. I think Electron is a lot more powerful for this and worth the overhead.

Qix- commented 8 years ago

especially since screensavers are non-interactable. (You move the mouse and it exits)

Not necessarily true. I remember screensavers that did quite a bit of badass stuff upon interacting with them.

RangerMauve commented 8 years ago

On the Mac

As cool as macs are, cross platform would be way more appealing IMHO..

gabrielstuff commented 8 years ago

Would be a dream :D

mieky commented 8 years ago

I'm dreaming of one day packaging my GIF looper into a configurable standalone screen saver, and Electron would be quite the perfect fit for this.

jamesjessian commented 8 years ago

Has anyone managed this yet? I had the same idea and found this thread looking for anyone who had achieved it. AFAIK, a Windows screensaver is just an executable renamed to have the .scr extension (like @RangerMauve said) and installed into the Windows/System32 directory, and I think from memory the program will get called with a /s flag if someone clicks the "Settings" link from the Control Panel -> Display settings. But can an Electron app be bundled into one single executable? If not, what's the easiest way to create an executable that executes my electron app that I can chuck in Windows/System32? I've just found out that my company have disabled any screen savers on our laptops so I can't actually make use of all this at all, but I'm still interested :)

Maybe I can set one up as a scheduled task...

Qix- commented 8 years ago

can an Electron app be bundled into one single executable?

It can be on OS X in particular. Not sure about linux, and I would be surprised if it couldn't on windows (though it might need some data folder somewhere else on the system - packaging into a single .exe is tricky and generally not very performant).

polyfeux commented 8 years ago

@RandScullard did it: https://github.com/RandScullard/photo-screen-saver

RandScullard commented 8 years ago

Yup, I did it -- only for Windows. If some like-minded developer out there were to send me a PR to add support for other platforms, I wouldn't object... :smile:

jamesjessian commented 8 years ago

This is cool :) :+1:

qroft commented 8 years ago

I started a "screensaver in the cloud" project back in 2007. A few months ago i made a Chrome application that allows you to create a playlist of pre-designed fullscreen widgets (https://chrome.google.com/webstore/detail/seemiyah-player-v2/dejoonkgljcpinhbnpilpfkecigiaplj) and start it via the Chrome App starter . A few weeks ago Google published that they will remove the App starter. And last week they informed that packaged Applications won't work from 2018 on. So i now came up with the idea to create Electron exectuables just like @RandScullard did. I will keep you updated on my progress.

qroft commented 8 years ago

One question: is there any solution on how to make the file smaller? I am having an average of 50MB, what imho is a lot for a simple screensaver :(

UPDATE: I found several sources informing about the fact that electron projects itself once compiled will be roundabout 50MB. That's sad to hear. So instead of making individual screensavers i might create the above mentioned Chrome extension into an Electron project. We will see. Thanks guys for your info!

112KA commented 6 years ago

I also want to make the electron application screensaver. If possible I'd like to make it single executable. http://www.boxedapp.com/boxedapppacker/usecases/pack_electron_app_into_single_exe.html this service seems good. I have not tried it yet. How does this service assemble? If someone knows, please tell me the hint.

wysiwyggins commented 5 years ago

I'm also trying to figure out how to do this, especially since Mojave just killed the ability to make native mac screensavers in Quartz Composer. I don't have a lot of experience making electron apps, but if it will hit both mac and pc targets I'm game!

wangrongding commented 1 year ago

I've been trying to make a macOS screensaver based on electron lately, and I'm waiting for a best practice here~ 👀