untested browser opening on Android
I've found multiple references to using the `am` command from the adb shell to open a browser. So I assume it also works in a terminal emulator.
This commit is contained in:
parent
b521b64cf4
commit
911506bc93
2 changed files with 13 additions and 6 deletions
|
@ -150,7 +150,7 @@ firstRun listenhost = do
|
||||||
sendurlback v _origout _origerr url _htmlshim = putMVar v url
|
sendurlback v _origout _origerr url _htmlshim = putMVar v url
|
||||||
|
|
||||||
openBrowser :: Maybe FilePath -> FilePath -> Maybe Handle -> Maybe Handle -> IO ()
|
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
|
hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url
|
||||||
environ <- cleanEnvironment
|
environ <- cleanEnvironment
|
||||||
(_, _, _, pid) <- createProcess p
|
(_, _, _, pid) <- createProcess p
|
||||||
|
@ -163,7 +163,9 @@ openBrowser cmd htmlshim outh errh = do
|
||||||
hPutStrLn (fromMaybe stderr errh) "failed to start web browser"
|
hPutStrLn (fromMaybe stderr errh) "failed to start web browser"
|
||||||
where
|
where
|
||||||
url = fileUrl htmlshim
|
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 -}
|
{- web.browser is a generic git config setting for a web browser program -}
|
||||||
webBrowser :: Git.Repo -> Maybe FilePath
|
webBrowser :: Git.Repo -> Maybe FilePath
|
||||||
|
|
|
@ -40,12 +40,17 @@ import Control.Concurrent
|
||||||
localhost :: HostName
|
localhost :: HostName
|
||||||
localhost = "localhost"
|
localhost = "localhost"
|
||||||
|
|
||||||
{- Command to use to run a web browser. -}
|
{- Builds a command to use to start or open a web browser showing an url. -}
|
||||||
browserCommand :: FilePath
|
browserProc :: String -> CreateProcess
|
||||||
#ifdef darwin_HOST_OS
|
#ifdef darwin_HOST_OS
|
||||||
browserCommand = "open"
|
browserProc url = proc "open" [url]
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
{- Binds to a socket on localhost, or possibly a different specified
|
{- Binds to a socket on localhost, or possibly a different specified
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue