Inspiration from: prashantgupta24/mac-sleep-notifier
pnpm add @oomol-lab/mac-power-monitor
# or
npm install @oomol-lab/mac-power-monitor
# or
yarn add @oomol-lab/mac-power-monitor
import { createMacPowerMonitor } from "@oomol-lab/mac-power-monitor";
const monitor = createMacPowerMonitor();
monitor.listenOnWillSleep(function () {
console.log("will sleep");
});
monitor.listenOnWillWake(function () {
console.log("will wake");
});
// when we don't need it
monitor.dispose();