diff options
-rw-r--r-- | Command/WebApp.hs | 6 | ||||
-rw-r--r-- | Utility/WebApp.hs | 13 |
2 files changed, 13 insertions, 6 deletions
diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 2d01b0d15..90abd4d27 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -150,7 +150,7 @@ firstRun listenhost = do sendurlback v _origout _origerr url _htmlshim = putMVar v url openBrowser :: Maybe FilePath -> FilePath -> Maybe Handle -> Maybe Handle -> IO () -openBrowser cmd htmlshim outh errh = do +openBrowser mcmd htmlshim outh errh = do hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url environ <- cleanEnvironment (_, _, _, pid) <- createProcess p @@ -163,7 +163,9 @@ openBrowser cmd htmlshim outh errh = do hPutStrLn (fromMaybe stderr errh) "failed to start web browser" where url = fileUrl htmlshim - p = proc (fromMaybe browserCommand cmd) [htmlshim] + p = case mcmd of + Just cmd -> proc cmd [htmlshim] + Nothing -> browserProc htmlshim {- web.browser is a generic git config setting for a web browser program -} webBrowser :: Git.Repo -> Maybe FilePath diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs index 97a6879ec..bafc9ac22 100644 --- a/Utility/WebApp.hs +++ b/Utility/WebApp.hs @@ -40,12 +40,17 @@ import Control.Concurrent localhost :: HostName localhost = "localhost" -{- Command to use to run a web browser. -} -browserCommand :: FilePath +{- Builds a command to use to start or open a web browser showing an url. -} +browserProc :: String -> CreateProcess #ifdef darwin_HOST_OS -browserCommand = "open" +browserProc url = proc "open" [url] #else -browserCommand = "xdg-open" +#ifdef __ANDROID__ +browserProc url = proc "am" + ["start", "-a", "android.intent.action.VIEW", "-d", url] +#else +browserProc url = proc "xdg-open" [url] +#endif #endif {- Binds to a socket on localhost, or possibly a different specified |