Example #1
0
func Notify(r Habit) {
	actionNotif := r.ToNotification()
	backNotif := nf.NewNotification(fmt.Sprintf("Back from %s after %v", r.Action, r.Wait))
	backNotif.Sound = BackSound

	for {
		time.Sleep(r.Interval)
		if err := actionNotif.Push(); err != nil {
			log.Printf("Failed to notify %#v: %v", actionNotif, err)
		}

		if r.Wait != NoWait {
			time.Sleep(r.Wait)
			if err := backNotif.Push(); err != nil {
				log.Printf("Failed to notify %#v: %v", backNotif, err)
			}
		}
	}
}
Example #2
0
func (r Habit) ToNotification() *nf.Notification {
	n := nf.NewNotification(r.Action)
	n.Sound = r.Sound
	return n
}