mrusme / neonmodem

Neon Modem Overdrive
https://neonmodem.com
GNU General Public License v3.0
582 stars 22 forks source link

Add support for defining custom URL browser in config #24

Closed tedwardd closed 1 year ago

tedwardd commented 1 year ago

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.

mrusme commented 1 year ago

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!