diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-28 18:23:34 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-28 18:23:34 -0400 |
commit | b7bc253ca3160578f88d05fd7f2d9dacae7b00dd (patch) | |
tree | a762feb4803dd9d4c970a3644b1332371e2452c6 /ControlWindow.hs | |
parent | 85914371f31952b30b062624feec35706382af95 (diff) | |
download | debug-me-b7bc253ca3160578f88d05fd7f2d9dacae7b00dd.tar.gz |
automatically open control window
Diffstat (limited to 'ControlWindow.hs')
-rw-r--r-- | ControlWindow.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ControlWindow.hs b/ControlWindow.hs index c22092f..cc63cef 100644 --- a/ControlWindow.hs +++ b/ControlWindow.hs @@ -7,8 +7,11 @@ module ControlWindow where import Types import CmdLine import ControlSocket +import VirtualTerminal import System.IO +import System.Environment +import System.Process import System.Posix import Control.Concurrent.Async import Control.Concurrent.STM @@ -16,12 +19,16 @@ import Control.Concurrent.STM.TMChan import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as L import Data.ByteString.UTF8 (fromString) +import Control.Monad import Data.Monoid import Prelude +winDesc :: String +winDesc = "debug-me session control and chat window" + controlWindow :: ControlOpts -> IO () controlWindow _ = do - putStrLn "** debug-me session control and chat window" + putStrLn $ "** " ++ winDesc socketfile <- defaultSocketFile ichan <- newTMChanIO ochan <- newTMChanIO @@ -46,8 +53,12 @@ openControlWindow = do ichan <- newTMChanIO ochan <- newTMChanIO _ <- async $ serveControlSocket soc ichan ochan + myexe <- getExecutablePath + mproc <- runInVirtualTerminal winDesc myexe ["--control"] + case mproc of + Nothing -> putStrLn "You need to open another shell prompt, and run: debug-me --control" + Just p -> void $ createProcess p -- Wait for message from control process. - putStrLn "You need to open another shell prompt, and run: debug-me --control" v <- atomically $ readTMChan ochan case v of Just ControlWindowOpened -> return () |