From 545642bd2bebb4419e2d7fc0f214c73d182f272a Mon Sep 17 00:00:00 2001 From: yory8 <> Date: Sun, 27 Oct 2019 23:18:46 +0100 Subject: [PATCH] fix: don't fail on missing wl-copy --- main.go | 16 +++++----------- storer.go | 5 +---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index d7fe05d..9ac9731 100644 --- a/main.go +++ b/main.go @@ -73,9 +73,7 @@ func main() { if selection != "" { // serve selection to the OS - if err := serveTxt(selection); err != nil { - log.Fatal(err) - } + serveTxt(selection) } case "restore": if len(history) == 0 { @@ -83,9 +81,7 @@ func main() { return } - if err := serveTxt(history[len(history)-1]); err != nil { - log.Fatal(err) - } + serveTxt(history[len(history)-1]) case "clear": // remove all history if *clearAll { @@ -167,16 +163,14 @@ func getHistory(rawPath string) (string, []string, error) { return histfile, history, nil } -func serveTxt(s string) error { +func serveTxt(s string) { bin, err := exec.LookPath("wl-copy") if err != nil { - return fmt.Errorf("couldn't find wl-copy: %v", err) + log.Printf("couldn't find wl-copy: %v\n", err) } cmd := exec.Cmd{Path: bin, Stdin: strings.NewReader(s)} if err := cmd.Run(); err != nil { - log.Printf("Error running wl-copy: %s", err) // don't abort, minor error + log.Printf("error running wl-copy: %s\n", err) } - - return nil } diff --git a/storer.go b/storer.go index a01f67d..2d9c8b1 100644 --- a/storer.go +++ b/storer.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io/ioutil" - "log" ) func store(text string, history []string, histfile string, max int, persist bool) error { @@ -42,9 +41,7 @@ func store(text string, history []string, histfile string, max int, persist bool // make the copy buffer available to all applications, // even when the source has disappeared if persist { - if err := serveTxt(text); err != nil { - log.Print(err) // don't abort, minor error - } + serveTxt(text) } return nil