module Web.Browser.Linux
( openBrowserLinux
) where

import System.Exit (ExitCode(..))
import System.Process (rawSystem)

openBrowserLinux :: String -> IO Bool
openBrowserLinux :: String -> IO Bool
openBrowserLinux String
url = ExitCode -> Bool
exitCodeToBool (ExitCode -> Bool) -> IO ExitCode -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` String -> [String] -> IO ExitCode
rawSystem String
executable [String]
argv
    where (String
executable, [String]
argv) = (String
"sh", [String
"-c", String
"xdg-open \"$0\" 2>&1 > /dev/null", String
url])
          exitCodeToBool :: ExitCode -> Bool
exitCodeToBool ExitCode
ExitSuccess     = Bool
True
          exitCodeToBool (ExitFailure Int
_) = Bool
False