github.com/pkg/browser is a great abstraction for opening file and web paths using the system default but it lacks the flexibility necessary to allow application developers to override the system default. On some systems, such as Linux, you can fudge this by wrapping neonmodem in a function that temporarily flips the default browser using xdg-mime but this is pretty crude and does not work cross platform.
This PR provides an additional config option to set the path to a custom executable path for neonmodem to use when opening URLs. This config option is then checked and an alternate code path is shimmed in before the call to browser in ui/windows/postsshow/handlers.go. The implementation of cmd used the same approached used by browser.OpenURL().
I've made the assumption that /path/to/browser postURL will launch the postURL in the defined browser using the browsers default behavior. I did my best to test this and I can confirm that setting it to the path for my Firefox binary works but I have not tested it with other browsers.
Hey @tedwardd, thank you for this PR! Looks good to me, since the Browser config is optional it shouldn't break anything in case it shouldn't work on non-*n?x systems. Lgtm!
github.com/pkg/browser
is a great abstraction for opening file and web paths using the system default but it lacks the flexibility necessary to allow application developers to override the system default. On some systems, such as Linux, you can fudge this by wrappingneonmodem
in a function that temporarily flips the default browser usingxdg-mime
but this is pretty crude and does not work cross platform.This PR provides an additional config option to set the path to a custom executable path for
neonmodem
to use when opening URLs. This config option is then checked and an alternate code path is shimmed in before the call tobrowser
inui/windows/postsshow/handlers.go
. The implementation ofcmd
used the same approached used bybrowser.OpenURL()
.I've made the assumption that
/path/to/browser postURL
will launch thepostURL
in the defined browser using the browsers default behavior. I did my best to test this and I can confirm that setting it to the path for my Firefox binary works but I have not tested it with other browsers.