Example #1
0
func main() {
	notify.Init("Hello World!")
	hello := notify.NotificationNew("Hello World!",
		"This is an example notification.",
		"")

	if hello == nil {
		fmt.Fprintf(os.Stderr, "Unable to create a new notification\n")
		return
	}
	// hello.SetTimeout(3000)
	notify.NotificationSetTimeout(hello, DELAY)

	// hello.Show()
	if e := notify.NotificationShow(hello); e != nil {
		fmt.Fprintf(os.Stderr, "%s\n", e.Message())
		return
	}

	time.Sleep(DELAY * 1000000)
	// hello.Close()
	notify.NotificationClose(hello)

	notify.UnInit()
}
Example #2
0
func init() {
	notify.Init("IRC-noti")

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	signal.Notify(c, os.Kill)
	go func() {
		for sig := range c {
			// sig is a ^C, handle it
			log.Printf("captured %v, stopping profiler and exiting..", sig)
			notify.UnInit()
			os.Exit(0)
		}
	}()
}
Example #3
0
func main() {
	file, err := os.Open("config.json")

	if err != nil {
		fmt.Println("Couldn`t read config file, stopping program.")
		panic(err)
	}

	decoder := json.NewDecoder(file)
	config := &Config{}
	decoder.Decode(&config)

	sigChan := make(chan os.Signal, 1)

	signal.Notify(sigChan, os.Interrupt)
	signal.Notify(sigChan, syscall.SIGTERM)
	signal.Notify(sigChan, syscall.SIGKILL)

	go func() {
		sigVal := <-sigChan
		cleanExit(sigVal)
	}()

	notify.Init("Nora")
	for {
		if IfFile(config.File) == false {
			time.Sleep(DELAY * time.Second)
			note := notify.NotificationNew("Message from Norad", "Vezi ca mor", "")
			go sendNote(note)
			time.Sleep(DELAY * 5 * time.Second)
			os.Exit(1)
			fmt.Printf("Am murit.") //doesn`t matter what you do after this point
		} else {
			time.Sleep(DELAY * time.Second)
		}
	}
}