mika76 / mamesaver

Mamesaver is a mame emulated screensaver - get all the good ol' games playing their demo modes while you procrastinate and enjoy!
https://mika76.github.io/mamesaver/
MIT License
37 stars 10 forks source link

Explicit sleep management #24

Closed nullpainter closed 6 years ago

nullpainter commented 6 years ago

This PR implements explicit sleep management, as per #23.

Sleep management is required because MAME ignores both screen and PC sleep settings. With this PR, the user's screens are turned off and MAME stopped based on the user's sleep settings. This makes Mamesaver a better citizen, is more environmentally friendly, and stops unnecessarily and constantly high CPU usage if the screensaver is left on overnight.

This change:

  1. Reads the user's preferences for putting the screen and PC to sleep
  2. Identifies the current power source
  3. Listens for power source change events
  4. Stops MAME and sleeps monitors when either screen or PC sleep times are reached

Note that no power actions other than sleeping screens is performed (i.e., we are treating requests to hibernate etc. as if it was a screen sleep event).

mika76 commented 6 years ago

I've merged the hotkeys one so I'm not sure if you need to merge here?

nullpainter commented 6 years ago

I created this branch from the hotkeys branch, so all should be well. I've done a sanity check on the commits.

mika76 commented 6 years ago

Hey @nullpainter I merged the multi screen PR and it seems to have some conflicts here - sorry about that...

nullpainter commented 6 years ago

No worries, @mika76. All done.

mika76 commented 6 years ago

Nice - I'll merge it quick 😉