// PlsNotify notifies you of begining and end of pomododo func PlsNotify(status string) { if status == "begin" { os := checkOsVersion() if os == "darwin" { cmd := exec.Command("bash", "-c", `osascript -e 'display notification "Pomodoro begins!" with title "Pomodoro"'`) _, err := cmd.Output() if err != nil { fmt.Println("Error sending notification") } } else if os == "linux" { notify = notificator.New(notificator.Options{ AppName: "Termodoro", }) notify.Push("Termordoro", "Pomodoro begins!", "", notificator.UR_NORMAL) } else if os == "window" { fmt.Println("Notifications aren't supported on your platform.") } } else if status == "end" { os := checkOsVersion() if os == "darwin" { cmd := exec.Command("bash", "-c", `osascript -e 'display notification "Your Pomodoro has ended!" with title "Pomodoro"'`) _, err := cmd.Output() if err != nil { fmt.Println("Error sending notification") } } else if os == "linux" { notify = notificator.New(notificator.Options{ AppName: "Termodoro", }) notify.Push("Termordoro", "Your pomodoro has ended!", "", notificator.UR_NORMAL) } else if os == "window" { fmt.Println("Notifications aren't supported on your platform.") } } }
func SendNotification(result []string) { var notify *notificator.Notificator notify = notificator.New(notificator.Options{ DefaultIcon: Icon, AppName: "Zabbix", }) for _, val := range result { notify.Push("Server Alert", val, Icon, notificator.UR_CRITICAL) } }
func showNotification(message string) { notify := notificator.New(notificator.Options{ DefaultIcon: "icon/default.png", AppName: "Timer", }) notify.Push("Take a Break", message, "", notificator.UR_CRITICAL) // Check errors // err := notify.Push("error", "ops =(", "", notificator.UR_CRITICAL) //if err != nil { // log.Fatal(err) //} }
func init() { const ( defaultDuration = "25m" durationUsage = "Duration, e.g. 1m30s or 90s" silenceUsage = "Suppresses the notification after the timer ends" ) flag.StringVar(&duration, "duration", defaultDuration, durationUsage) flag.StringVar(&duration, "d", defaultDuration, durationUsage+" (shorthand)") flag.BoolVar(&silence, "silence", false, silenceUsage) flag.BoolVar(&silence, "s", false, silenceUsage+" (shorthand)") flag.Parse() notify = notificator.New(notificator.Options{ DefaultIcon: "icon/default.png", AppName: "Pomodoro", }) }
func main() { var database DataBase var notify *notificator.Notificator notify = notificator.New(notificator.Options{ DefaultIcon: "icon/default.png", AppName: "Youtube", }) database.session, _ = mgo.Dial("localhost:27017") defer database.session.Close() fmt.Println("session connected to mongodb") c := database.session.DB("youtube").C("toDownload") var R *Result //fmt.Println(*R) iter := c.Find(nil).Sort("$natural").Tail(time.Second * 5) for { for iter.Next(&R) { Res := R fmt.Println("Added result : " + Res.Url) notify.Push("Youtube Video", Res.Url, "", notificator.UR_NORMAL) mack.Notify(Res.Url, "Youtube") if !R.isDownloaded(&database) { go func(Res *Result) { err := R.download() if err == nil { Res.updateDB(&database) fmt.Println("waiting for : " + Res.Url) if err != nil { fmt.Println("Error while downloading video : " + Res.Url) fmt.Println(err) } } }(Res) } else { log.Printf("Video is already downloaded ", R.Url) } } } }
"fmt" "os" "path/filepath" "github.com/0xAX/notificator" ) var imagePath string func init() { defaultIconLocation := fmt.Sprintf("%s/%s", os.Getenv("HOME"), "pomodogo/icon.png") flag.StringVar(&imagePath, "icon", defaultIconLocation, "location of notification icon") } var notify = notificator.New(notificator.Options{ DefaultIcon: getImagePath("tomato.png"), AppName: "PomodoGo", }) func showMessage(message string) { notify.Push("PomodoGo!", message, imagePath, notificator.UR_CRITICAL) } func getImagePath(fileName string) string { dir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { return fileName } return fmt.Sprintf("%s/%s", dir, fileName) } // Finish displays system notification about finished Pomodoro period.
// Initializes the GUI. Function is passed to ui.Do. func initGui() { var cs, ps, ns song var player *gst.Element var playing bool // Creates the initial songs that will be used as long as the program runs. cs = song{api: ¤t.Current.songAPIType} ps = song{api: ¤t.Previous1.songAPIType} // ps2 := song{api: ¤t.Previous2.songAPIType} ns = song{api: ¤t.Next1.songAPIType} // ns2 := song{api: ¤t.Next2.songAPIType} // Creates the player and the controls for the player (as well as label). player = initPlayer() playing = true psl := ui.NewLabel("Currently Playing") ppbtn := ui.NewButton("Pause") ppbtn.OnClicked(func() { if playing { ppbtn.SetText("Play") player.SetState(gst.STATE_PAUSED) psl.SetText("Currently Paused") } else { ppbtn.SetText("Pause") psl.SetText("Currently Playing") player.SetState(gst.STATE_PLAYING) } playing = !playing }) // Creates the notification system nt := notificator.New(notificator.Options{ DefaultIcon: "icon/default.png", AppName: "GoFip", }) // Notification settings. Will be passed to the updateGui goroutine to Check // whether or not to send a system notification when the music changes. ntc := ui.NewCheckbox("Notifications") ntc.SetChecked(true) // Defines a closableTicker that is used in the updateGui goroutine // This allows to close the ticker when the setting button is unchecked. ct := closableTicker{ ticker: time.NewTicker(1 * time.Minute), halt: make(chan bool, 1), } prc := ui.NewCheckbox("Periodic Check") prc.SetChecked(true) prc.OnToggled(func() { if !prc.Checked() { ct.stop() } else { ct = closableTicker{ ticker: time.NewTicker(1 * time.Minute), halt: make(chan bool, 1), } go updateGui(ct, nt, ntc, &cs, &ps, &ns) } }) // Start the goroutine to update the GUI every minute (default behaviour) // Uses the closableTicker defined earlier so the goroutine can be stopped. go updateGui(ct, nt, ntc, &cs, &ps, &ns) // Creating the tabs with the songs as well as settings and credits. createTabs(&cs, &ps, &ns) ts := ui.NewTab() ts.Append("Current", cs.stack) ts.Append("Previous", ps.stack) ts.Append("Next", ns.stack) ts.Append("Settings", ui.NewVerticalStack(ntc, prc)) ts.Append("Credits", ui.NewLabel("Depado 2015")) // Creates the main vertical stack that is passed to the main window. mvs := ui.NewVerticalStack(ts, ppbtn, psl) // The tab control must be set to stretchy otherwise it won't display the content. mvs.SetStretchy(0) // Creates the main window and the behaviour on close event. window = ui.NewWindow("GoFIP", width, height, mvs) window.OnClosing(func() bool { ui.Stop() return true }) window.Show() // Starts the player once the window is shown. player.SetState(gst.STATE_PLAYING) }
func Layout(g *gocui.Gui) error { maxX, maxY := g.Size() notify = notificator.New(notificator.Options{ AppName: Name, }) // if _, err := g.SetView("sidebar", -1, -1, int(0.2*float32(maxX)), maxY-3); err != nil { // if err != gocui.ErrorUnkView { // return err // } // } if err := HeaderView(g, -1, -1, maxX, 1); err != nil { panic(err) } if _, _, ok := Server.HasChannel(client.StatusChannel); !ok { status := client.Channel{ Status: true, Name: client.StatusChannel, MaxX: maxX, MaxY: maxY, RenderHandler: func(channel *client.Channel, view *gocui.View) error { view.Autoscroll = true view.Wrap = true view.Frame = false // view.FgColor = gocui.ColorGreen view.BgColor = gocui.ColorDefault fmt.Fprintln(view, "") fmt.Fprintln(view, Logo) fmt.Fprintln(view, color.GreenString(VersionLine)) client.StatusMessage(view, fmt.Sprintf("Welcome to the %s IRC client.", Name)) client.StatusMessage(view, "Type /help for a list of commands.\n") return nil }, } Server.AddChannel(&status) logger.Logger.Printf("LAYOUT %p %p\n", g, Server.Gui) if err := status.Render(false); err != nil { return err } BindHandlers() } else { for _, c := range Server.Channels { c.Update() } } if err := MenuView(g, maxX, maxY); err != nil { return err } // if err := InputView(g, 20, maxY-2, maxX, maxY); err != nil { // return err // } return nil }