mac-sleep-notifier
OSX Sleep/Wake notifications in golang
About mac-sleep-notifier
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
Frequently Asked Questions
What is mac-sleep-notifier?
mac-sleep-notifier is a GUI library for the Go programming language. OSX Sleep/Wake notifications in golang
How do I install mac-sleep-notifier?
Install mac-sleep-notifier with the Go module system using `go get prashantgupta24/mac-sleep-notifier`. Check the repository for the current installation instructions.
What category does mac-sleep-notifier belong to?
mac-sleep-notifier is listed under GUI, specifically GUI.