Use "open" instead of "xdg-open" on Darwin systems

This commit is contained in:
Ben Burwell 2019-07-02 18:21:34 -04:00 committed by Drew DeVault
parent 687f1d8c1a
commit 1bb1a80156
4 changed files with 25 additions and 4 deletions

View file

@ -7,10 +7,10 @@ import (
"io/ioutil" "io/ioutil"
"mime/quotedprintable" "mime/quotedprintable"
"os" "os"
"os/exec"
"strings" "strings"
"time" "time"
"git.sr.ht/~sircmpwn/aerc/lib"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
) )
@ -58,8 +58,7 @@ func (_ Open) Execute(aerc *widgets.Aerc, args []string) error {
return return
} }
cmd := exec.Command("xdg-open", tmpFile.Name()) err = lib.OpenFile(tmpFile.Name())
err = cmd.Run()
if err != nil { if err != nil {
aerc.PushError(" " + err.Error()) aerc.PushError(" " + err.Error())
} }

View file

@ -122,7 +122,7 @@ message list, the message in the message viewer, etc).
*open* *open*
Saves the current message part in a temporary file and opens it Saves the current message part in a temporary file and opens it
with xdg-open. with the system handler.
*pipe* <cmd> *pipe* <cmd>
Downloads and pipes the current message part into the given shell command, Downloads and pipes the current message part into the given shell command,

12
lib/open.go Normal file
View file

@ -0,0 +1,12 @@
// +build !darwin
package lib
import (
"os/exec"
)
func OpenFile(filename string) error {
cmd := exec.Command("xdg-open", filename)
return cmd.Run()
}

10
lib/open_darwin.go Normal file
View file

@ -0,0 +1,10 @@
package lib
import (
"os/exec"
)
func OpenFile(filename string) error {
cmd := exec.Command("open", filename)
return cmd.Run()
}