summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/open.go15
-rw-r--r--lib/open_darwin.go15
2 files changed, 26 insertions, 4 deletions
diff --git a/lib/open.go b/lib/open.go
index ad6533e..ebcf878 100644
--- a/lib/open.go
+++ b/lib/open.go
@@ -6,7 +6,18 @@ import (
 	"os/exec"
 )
 
-func OpenFile(filename string) error {
+func OpenFile(filename string, onErr func(error)) {
 	cmd := exec.Command("xdg-open", filename)
-	return cmd.Run()
+	err := cmd.Start()
+	if err != nil && onErr != nil {
+		onErr(err)
+		return
+	}
+
+	go func() {
+		err := cmd.Wait()
+		if err != nil && onErr != nil {
+			onErr(err)
+		}
+	}()
 }
diff --git a/lib/open_darwin.go b/lib/open_darwin.go
index 0ffd9a1..d98c898 100644
--- a/lib/open_darwin.go
+++ b/lib/open_darwin.go
@@ -4,7 +4,18 @@ import (
 	"os/exec"
 )
 
-func OpenFile(filename string) error {
+func OpenFile(filename string, onErr func(error)) {
 	cmd := exec.Command("open", filename)
-	return cmd.Run()
+	err := cmd.Start()
+	if err != nil && onErr != nil {
+		onErr(err)
+		return
+	}
+
+	go func() {
+		err := cmd.Wait()
+		if err != nil && onErr != nil {
+			onErr(err)
+		}
+	}()
 }