store tomato icon in config path
This commit is contained in:
parent
31f1cfaa4e
commit
d7863cb264
6
main.go
6
main.go
|
@ -9,9 +9,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func notifier() Notifier {
|
func notifier(iconPath string) Notifier {
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
return NewLibNotifier()
|
return NewLibNotifier(iconPath)
|
||||||
}
|
}
|
||||||
return NoopNotifier{}
|
return NoopNotifier{}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func start(path *string) func(*cli.Cmd) {
|
||||||
NPomodoros: *pomodoros,
|
NPomodoros: *pomodoros,
|
||||||
Duration: parsed,
|
Duration: parsed,
|
||||||
}
|
}
|
||||||
runner, err := NewTaskRunner(task, db, notifier())
|
runner, err := NewTaskRunner(task, db, notifier(*path+"/icon.png"))
|
||||||
maybe(err)
|
maybe(err)
|
||||||
runner.Start()
|
runner.Start()
|
||||||
startUI(runner)
|
startUI(runner)
|
||||||
|
|
14
types.go
14
types.go
|
@ -159,16 +159,18 @@ type LibNotifier struct {
|
||||||
iconPath string
|
iconPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLibNotifier() Notifier {
|
func NewLibNotifier(iconPath string) Notifier {
|
||||||
ln := &LibNotifier{
|
ln := &LibNotifier{
|
||||||
client: libnotify.NewClient(),
|
client: libnotify.NewClient(),
|
||||||
}
|
}
|
||||||
// Write the tomato icon to a temp path
|
// Write the built-in tomato icon if it
|
||||||
|
// doesn't already exist.
|
||||||
|
_, err := os.Stat(iconPath)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
raw := MustAsset("tomato-icon.png")
|
raw := MustAsset("tomato-icon.png")
|
||||||
fp, _ := ioutil.TempFile("", "pomo")
|
ioutil.WriteFile(iconPath, raw, 0644)
|
||||||
fp.Write(raw)
|
}
|
||||||
ln.iconPath = fp.Name()
|
ln.iconPath = iconPath
|
||||||
fp.Close()
|
|
||||||
return ln
|
return ln
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue