fix(selector): don't spawn wl-copy if no selection
This commit is contained in:
parent
11ad8149ad
commit
824b31c50f
1 changed files with 9 additions and 5 deletions
4
main.go
4
main.go
|
@ -66,10 +66,12 @@ func main() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if selection != "" {
|
||||||
// serve selection to the OS
|
// serve selection to the OS
|
||||||
if err := exec.Command("wl-copy", []string{"--", selection}...).Run(); err != nil {
|
if err := exec.Command("wl-copy", []string{"--", selection}...).Run(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case "clear":
|
case "clear":
|
||||||
histfile, history, err := getHistory(*histpath)
|
histfile, history, err := getHistory(*histpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -89,10 +91,12 @@ func main() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if selection != "" {
|
||||||
if err := write(filter(history, selection), histfile); err != nil {
|
if err := write(filter(history, selection), histfile); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHistory(rawPath string) (string, []string, error) {
|
func getHistory(rawPath string) (string, []string, error) {
|
||||||
|
|
Loading…
Reference in a new issue