on warp-tls/1.4.1.1 help sign in
typeable/wai/wai-handler-devel/run-onreloadapp.hs
23 lines 807 B history raw
2import Network.Wai.Handler.DevelServer (runQuitWithReloadActions)
3import System.Directory(findExecutable)
4import System.Process(readProcess)
6main :: IO ()
7main = runQuitWithReloadActions 4000 "SmallApp" "smallApp" (const $ return []) [browserRefresh]
9browserRefresh :: IO (IO ())
10browserRefresh = do
11 exe <- findExecutable "xdotool"
12 case exe of
13 Nothing -> do
14 putStrLn "Install xdotool for automatic browser refresh"
15 return $ return ()
16 Just xdotool -> do
17 putStrLn "Please click on the browser window..."
18 pid <- readProcess xdotool ["selectwindow"] ""
19 return $ do
20 current <- readProcess xdotool ["getwindowfocus"] ""
21 let cmds = ["windowfocus", pid, "key", "F5", "windowfocus", current]
22 _ <- readProcess xdotool cmds ""
23 return ()