1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-11-03 04:27:16 -05:00

Merge pull request #24 from tedwardd/custom_browser_support

Add support for defining custom URL browser in config
This commit is contained in:
mrusme 2023-06-14 15:09:33 -05:00 committed by GitHub
commit dd2bfd8504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {