2019-08-16 09:20:56 +01:00
|
|
|
/*
|
|
|
|
Pominal
|
2020-02-11 16:27:47 +00:00
|
|
|
Copyright (C) 2020 Daniel Anglin
|
2019-08-16 09:20:56 +01:00
|
|
|
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/0xAX/notificator"
|
|
|
|
)
|
|
|
|
|
2020-07-14 19:57:02 +01:00
|
|
|
const iconPath string = "share/pominal/icons/tomato.png"
|
2019-08-16 09:20:56 +01:00
|
|
|
|
|
|
|
// initNotifier initialises the new desktop notifier.
|
2020-01-24 09:51:21 +00:00
|
|
|
func initNotifier() *notificator.Notificator {
|
|
|
|
return notificator.New(notificator.Options{
|
2020-07-14 19:57:02 +01:00
|
|
|
DefaultIcon: installPrefix + "/" + iconPath,
|
2019-08-16 09:20:56 +01:00
|
|
|
AppName: "Pominal",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-09-18 09:08:12 +01:00
|
|
|
// alert creates a new desktop notification.
|
2020-02-13 12:42:55 +00:00
|
|
|
func desktopAlert(label, msg string, notifier *notificator.Notificator) {
|
|
|
|
if len(msg) == 0 {
|
|
|
|
msg = fmt.Sprintf(defaultNotificationMsgFmt, label)
|
|
|
|
}
|
|
|
|
|
|
|
|
title := fmt.Sprintf("Pominal session: %s", label)
|
2020-01-24 09:51:21 +00:00
|
|
|
|
2020-02-13 12:42:55 +00:00
|
|
|
_ = notifier.Push(title, msg, "", notificator.UR_NORMAL)
|
2019-08-16 09:20:56 +01:00
|
|
|
}
|