refactor run loop, add simple libnotify support, improve notifications, binpack tomato image
parent
cb5779343f
commit
85c4f20f8c
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
.PHONY: \
|
||||||
|
all
|
||||||
|
|
||||||
|
all: bin/pomo
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -v bin/pomo bindata.go
|
||||||
|
|
||||||
|
bindata.go:
|
||||||
|
go-bindata -pkg main -o $@ tomato-icon.png
|
||||||
|
|
||||||
|
bin/pomo: bindata.go
|
||||||
|
mkdir bin 2>/dev/null
|
||||||
|
go build -o bin/pomo
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
libnotify is a lightweight client for libnotify https://developer.gnome.org/notification-spec/.
|
||||||
|
For now this just shells out to "notify-send".
|
||||||
|
TODO: Move this into it's own repository as time permits.
|
||||||
|
*/
|
||||||
|
package libnotify
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Notification struct {
|
||||||
|
Urgency string
|
||||||
|
Expire time.Duration
|
||||||
|
Title string
|
||||||
|
Body string
|
||||||
|
Icon string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() *Client {
|
||||||
|
return &Client{
|
||||||
|
Path: "/bin/notify-send",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) Notify(n Notification) error {
|
||||||
|
var args []string
|
||||||
|
if n.Urgency != "" {
|
||||||
|
args = append(args, fmt.Sprintf("--urgency=%s", n.Urgency))
|
||||||
|
}
|
||||||
|
if n.Icon != "" {
|
||||||
|
args = append(args, fmt.Sprintf("--icon=%s", n.Icon))
|
||||||
|
}
|
||||||
|
if n.Expire > 0 {
|
||||||
|
args = append(args, fmt.Sprintf("--expire=%s", n.Expire.Truncate(time.Millisecond)))
|
||||||
|
}
|
||||||
|
args = append(args, n.Title)
|
||||||
|
args = append(args, n.Body)
|
||||||
|
_, err := exec.Command(c.Path, args...).Output()
|
||||||
|
return err
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue