fix: don't kill demon on wl-clipboard errors
This commit is contained in:
parent
a64d7bdf66
commit
7f5078bfdb
2 changed files with 4 additions and 7 deletions
7
demon.go
7
demon.go
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -42,7 +41,7 @@ func filter(history []string, text string) []string {
|
||||||
return history
|
return history
|
||||||
}
|
}
|
||||||
|
|
||||||
func listen(history []string, histfile string, persist bool, max int) error {
|
func listen(history []string, histfile string, persist bool, max int) {
|
||||||
for {
|
for {
|
||||||
|
|
||||||
t, err := exec.Command("wl-paste", "-n").CombinedOutput()
|
t, err := exec.Command("wl-paste", "-n").CombinedOutput()
|
||||||
|
@ -90,14 +89,14 @@ func listen(history []string, histfile string, persist bool, max int) error {
|
||||||
// dump history to file so that other apps can query it
|
// dump history to file so that other apps can query it
|
||||||
err = write(history, histfile)
|
err = write(history, histfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error writing history (demon.83): %s", err)
|
log.Fatalf("Fatal error writing history (demon.83): %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if persist {
|
if persist {
|
||||||
// make the copy buffer available to all applications,
|
// make the copy buffer available to all applications,
|
||||||
// even when the source has disappeared
|
// even when the source has disappeared
|
||||||
if err := exec.Command("wl-copy", []string{"--", text}...).Run(); err != nil {
|
if err := exec.Command("wl-copy", []string{"--", text}...).Run(); err != nil {
|
||||||
return fmt.Errorf("error running wl-copy (demon.91): %s", err)
|
log.Printf("Error running wl-copy (demon.91): %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
main.go
4
main.go
|
@ -42,9 +42,7 @@ func main() {
|
||||||
|
|
||||||
if *asDemon {
|
if *asDemon {
|
||||||
persist := !*noPersist
|
persist := !*noPersist
|
||||||
if err := listen(history, histfile, persist, *max); err != nil {
|
listen(history, histfile, persist, *max)
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
} else if *asSelector {
|
} else if *asSelector {
|
||||||
if err := selector(history, *max, *tool); err != nil {
|
if err := selector(history, *max, *tool); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in a new issue