pominal/alert.go
Dan Anglin ec84a11036
feat: install Pominal with make
This commit adds an install target in the Makefile to install
Pominal on the user's system. The default installation path is
/usr/local/bin but this can be configured by overriding the
INSTALL_PREFIX variable.

Changes include:

- cleaning up .gitignore
- adding workflow to .gitlab-ci.yml
- bumping Go version in .gitlab-ci.yml
- excluding main.go for gochecknoglobals
- adding copyright notice in Makefile
- adding install and uninstall targets in Makefile
- adding installation instructions in the README
- adding a config.mk file for make arguments
- updating Pominal to specify where the icon is installed
2020-07-14 19:57:02 +01:00

46 lines
1.3 KiB
Go

/*
Pominal
Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
*/
package main
import (
"fmt"
"github.com/0xAX/notificator"
)
const iconPath string = "share/pominal/icons/tomato.png"
// initNotifier initialises the new desktop notifier.
func initNotifier() *notificator.Notificator {
return notificator.New(notificator.Options{
DefaultIcon: installPrefix + "/" + iconPath,
AppName: "Pominal",
})
}
// alert creates a new desktop notification.
func desktopAlert(label, msg string, notifier *notificator.Notificator) {
if len(msg) == 0 {
msg = fmt.Sprintf(defaultNotificationMsgFmt, label)
}
title := fmt.Sprintf("Pominal session: %s", label)
_ = notifier.Push(title, msg, "", notificator.UR_NORMAL)
}