Browse Source

don't assume xdg-open, use open on iOS and start on Windows

pull/253/head
Rasmus Lindroth 3 years ago
parent
commit
f5739d083a
  1. 7
      config/config.go
  2. 10
      config/toml_default.go
  3. 23
      util/xdg.go

7
config/config.go

@ -809,6 +809,11 @@ func getViewer(v *ViewerTOML, def *ViewerTOML) (program, args string, terminal,
if v.Reverse != nil {
reverse = *v.Reverse
}
if *v.Program == "TUT_OS_DEFAULT" {
var argsSlice []string
program, argsSlice = util.GetDefaultForOS()
args = strings.Join(argsSlice, " ")
}
return
}
@ -851,7 +856,7 @@ func parseGeneral(cfg GeneralTOML) General {
def := ConfigDefault.General
general.Editor = NilDefaultString(cfg.Editor, def.Editor)
if general.Editor == "USE_TUT_INTERNAL" {
if general.Editor == "TUT_USE_INTERNAL" {
general.UseInternalEditor = true
}
general.Confirmation = NilDefaultBool(cfg.Confirmation, def.Confirmation)

10
config/toml_default.go

@ -19,7 +19,7 @@ func ip64(i int64) *int64 {
var ConfigDefault = ConfigTOML{
General: GeneralTOML{
Editor: sp("USE_TUT_INTERNAL"),
Editor: sp("TUT_USE_INTERNAL"),
Confirmation: bt,
MouseSupport: bf,
DateFormat: sp("2006-01-02 15:04"),
@ -89,28 +89,28 @@ var ConfigDefault = ConfigTOML{
},
Media: MediaTOML{
Image: &ViewerTOML{
Program: sp("xdg-open"),
Program: sp("TUT_OS_DEFAULT"),
Args: sp(""),
Terminal: bf,
Single: bt,
Reverse: bf,
},
Video: &ViewerTOML{
Program: sp("xdg-open"),
Program: sp("TUT_OS_DEFAULT"),
Args: sp(""),
Terminal: bf,
Single: bt,
Reverse: bf,
},
Audio: &ViewerTOML{
Program: sp("xdg-open"),
Program: sp("TUT_OS_DEFAULT"),
Args: sp(""),
Terminal: bf,
Single: bt,
Reverse: bf,
},
Link: &ViewerTOML{
Program: sp("xdg-open"),
Program: sp("TUT_OS_DEFAULT"),
Args: sp(""),
Terminal: bf,
Single: bt,

23
util/xdg.go

@ -1,7 +1,26 @@
package util
import "os/exec"
import (
"os/exec"
"runtime"
)
func GetDefaultForOS() (program string, args []string) {
switch runtime.GOOS {
case "windows":
program = "start"
args = []string{"/wait"}
case "darwin":
program = "open"
args = []string{"-W"}
default:
program = "xdg-open"
}
return program, args
}
func OpenURL(url string) {
exec.Command("xdg-open", url).Start()
program, args := GetDefaultForOS()
args = append(args, url)
exec.Command(program, args...).Start()
}

Loading…
Cancel
Save