diff --git a/main.go b/main.go index d52c830..b3d7597 100644 --- a/main.go +++ b/main.go @@ -9,9 +9,9 @@ import ( "time" ) -func notifier() Notifier { +func notifier(iconPath string) Notifier { if runtime.GOOS == "linux" { - return NewLibNotifier() + return NewLibNotifier(iconPath) } return NoopNotifier{} } @@ -37,7 +37,7 @@ func start(path *string) func(*cli.Cmd) { NPomodoros: *pomodoros, Duration: parsed, } - runner, err := NewTaskRunner(task, db, notifier()) + runner, err := NewTaskRunner(task, db, notifier(*path+"/icon.png")) maybe(err) runner.Start() startUI(runner) diff --git a/types.go b/types.go index 8af6b13..5293e5f 100644 --- a/types.go +++ b/types.go @@ -159,16 +159,18 @@ type LibNotifier struct { iconPath string } -func NewLibNotifier() Notifier { +func NewLibNotifier(iconPath string) Notifier { ln := &LibNotifier{ client: libnotify.NewClient(), } - // Write the tomato icon to a temp path - raw := MustAsset("tomato-icon.png") - fp, _ := ioutil.TempFile("", "pomo") - fp.Write(raw) - ln.iconPath = fp.Name() - fp.Close() + // 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") + ioutil.WriteFile(iconPath, raw, 0644) + } + ln.iconPath = iconPath return ln }