mac-sleep-notifier

module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2019 License: MIT

README

Go Report Card codecov version godoc-badge

macOS Sleep/ Wake notifications in golang

Inspired from this blog.

This libary notifies through a channel whenever your machine is put to sleep or is woken up. Calling the Start function will get you a channel on which you receive both Sleep and Awake activities.

Installation

go get -u github.com/prashantgupta24/mac-sleep-notifier/notifier

Usage

notifierCh := notifier.GetInstance().Start()

for {
	select {
	case activity := <-notifierCh:
		if activity.Type == notifier.Awake {
			log.Println("machine awake")
		} else {
			if activity.Type == notifier.Sleep {
				log.Println("machine sleeping")
			}
		}
	}
}

Example

See example here

Directories

Path Synopsis
Package notifier notifies through a channel whenever your machine is put to sleep or is woken up.
Package notifier notifies through a channel whenever your machine is put to sleep or is woken up.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL