Documentation ¶
Overview ¶
Package notifier 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 ¶
The library can be installed using:
go get -u github.com/prashantgupta24/mac-sleep-notifier/notifier
Usage ¶
The usage is as following:
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") } } } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartNotifier ¶
func StartNotifier()
StartNotifier starts the internal notifier function which communicates with the C library.
func StopNotifier ¶
func StopNotifier()
StopNotifier stops the internal notifier function which communicates with the C library.
Types ¶
type Activity ¶
type Activity struct {
Type Type
}
Activity struct is used to hold the sleep and awake activity.
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier notifies about the sleep/wake events
func GetInstance ¶
func GetInstance() *Notifier
GetInstance gets the singleton instance for the notifier
Click to show internal directories.
Click to hide internal directories.