aerc/lib/open_darwin.go
Andrew Jeffery fda3f43e7c Allow open to be asynchronous
This stops the ui being blocked while the resource is opened. The wait
ensures that resources are reclaimed when the process finishes while
aerc is still running.
2020-07-08 09:07:43 +02:00

21 lines
298 B
Go

package lib
import (
"os/exec"
)
func OpenFile(filename string, onErr func(error)) {
cmd := exec.Command("open", filename)
err := cmd.Start()
if err != nil && onErr != nil {
onErr(err)
return
}
go func() {
err := cmd.Wait()
if err != nil && onErr != nil {
onErr(err)
}
}()
}