I modified the first example in https://hackage.haskell.org/package/svg-builder with the following 2 little changes:
- Additional imports:
import Data.Text
import qualified Data.Text.Lazy.IO as TLIO
import Web.Browser(openBrowser)
- New
main
program that writes the svg data to a file and then opens the browser with this file:
main = do
TLIO.writeFile "test.svg" $ renderText $ svg contents
openBrowser "test.svg" >>= print
The openBrowser
comes from https://hackage.haskell.org/package/open-browser
When I run this program, my Debian (11.6) opens the Gimp
program and not the browser.
When I double click on the written file in Nautilus, then the browser opens.
Where and what do I have to tweak, so that the Haskell program also opens the browser?
2
Answers
After reading about the xdg-mime command I did:
and this solves the issue for the moment.
Looking at the code for the Browser library you’re using, (at the time of writing):
It is calling out to
xdg-open
which according to the man page forxdg-open
:To get this working on your system, you’ll need to update the default program that handles
svg
files to be your preferred browser.Getting this working in general is probably a larger task since the issue seems to be with the implementation in the library itself. You might want to bring it up with the library’s maintainers or consider looking for another library.