/* Pominal Copyright (C) 2019 Daniel Anglin This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package main import ( "fmt" "os" "path/filepath" "github.com/0xAX/notificator" ) const iconPath string = "assets/icon/tomato.png" var notifier *notificator.Notificator // initNotifier initialises the new desktop notifier. func initNotifier() { notifier = notificator.New(notificator.Options{ DefaultIcon: getIconPath(), AppName: "Pominal", }) } // getIconPath returns the absolute path of the tomoato icon // used for desktop notifications. // If there is an error getting the path to the executing program // then an empty string is returned. func getIconPath() string { var result string exe, err := os.Executable() if err != nil { fmt.Printf("ERROR: Unable to determine path to this executable. %s", err.Error()) return result } result = filepath.Dir(exe) + "/" + iconPath return result } // alert pushes a desktop notification func alert(oldLabel, newLabel string) { title := oldLabel + " timer has stopped" text := newLabel + " timer has started" notifier.Push(title, text, "", notificator.UR_NORMAL) }