kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.36k stars 128 forks source link

Is there a way to detect/react to system sleep events? #282

Closed d1rewolf closed 2 years ago

d1rewolf commented 3 years ago

I'd like to be able to do certain actions when my system goes to sleep. In Hammerspoon, they have https://www.hammerspoon.org/docs/hs.caffeinate.watcher.html which works very well. I'm trying to find the equivalent in Phoenix. The closest I've found screensDidChange, but this doesn't seem to fire on system sleep.

Is there a way to do this currently?

Thanks!

kasper commented 2 years ago

Hey @d1rewolf! No way currently, these are the supported events https://github.com/kasper/phoenix/blob/2.6.7/docs/API.md#2-events. I haven’t tested, but I wonder if the app activation events could work as a stopgap?

d1rewolf commented 2 years ago

Thanks for the response. For the time, I've switched back to Hammerspoon, but still hope to revisit Phoenix in the future. I'll research that approach and post back here if I reach a conclusion.

kasper commented 2 years ago

Sure! I’ll reopen this one still, so I can keep it as an improvement idea.

kasper commented 2 years ago

Added support for deviceWillSleep and deviceDidWake. Read more at https://kasper.github.io/phoenix/api/events/#device.