1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-12-04 14:46:37 -05:00

Add support for defining custom URL browser in config

This commit is contained in:
Ted Wood 2023-06-14 11:21:57 -04:00
parent ba73eba439
commit a1acbb80b8
2 changed files with 29 additions and 4 deletions

View File

@ -42,7 +42,7 @@ type Config struct {
Debug bool
Log string
Proxy string
Browser string
RenderShadows bool
RenderImages bool
@ -188,6 +188,7 @@ func SetDefaults(cacheDir string) {
viper.SetDefault("Debug", "false")
viper.SetDefault("Log", path.Join(cacheDir, "neonmodem.log"))
viper.SetDefault("Proxy", "")
viper.SetDefault("Browser", "")
viper.SetDefault("RenderShadows", "true")
viper.SetDefault("RenderImages", "true")

View File

@ -2,6 +2,8 @@ package postshow
import (
"errors"
"os"
"os/exec"
"strconv"
"time"
@ -91,6 +93,28 @@ func handleOpen(mi interface{}) (bool, []tea.Cmd) {
var cmds []tea.Cmd
openURL := m.activePost.URL
browserPath := m.ctx.Config.Browser
if browserPath != "" {
if _, err := os.Stat(browserPath); err != nil {
m.ctx.Logger.Error(err)
cmds = append(cmds, cmd.New(
cmd.MsgError,
WIN_ID,
cmd.Arg{
Name: "error",
Value: err,
},
).Tea())
return true, cmds
}
cmd := exec.Command(browserPath, openURL)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
return true, cmds
}
browser.Stderr = nil
browser.Stdout = nil
if err := browser.OpenURL(openURL); err != nil {