From 189a665cfdd7be7e7b2ef11c1a81a6ca011944da Mon Sep 17 00:00:00 2001 From: Lukas Mai Date: Fri, 9 Nov 2007 00:09:33 +0100 Subject: refactor main, add "recompile" to XMonad.Core darcs-hash:20071108230933-462cf-b1e100cf8f2cecbfef925b870a3fc894fe47513c.gz --- XMonad/Core.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'XMonad') diff --git a/XMonad/Core.hs b/XMonad/Core.hs index e88082d..8d85afc 100644 --- a/XMonad/Core.hs +++ b/XMonad/Core.hs @@ -20,7 +20,7 @@ module XMonad.Core ( X, WindowSet, WindowSpace, WorkspaceId, ScreenId(..), ScreenDetail(..), XState(..), XConf(..), XConfig(..), LayoutClass(..), Layout(..), readsLayout, Typeable, Message, SomeMessage(..), fromMessage, runLayout, LayoutMessages(..), - runX, catchX, userCode, io, catchIO, withDisplay, withWindowSet, isRoot, getAtom, spawn, restart, trace, whenJust, whenX, + runX, catchX, userCode, io, catchIO, withDisplay, withWindowSet, isRoot, getAtom, spawn, restart, recompile, trace, whenJust, whenX, atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW ) where @@ -32,6 +32,8 @@ import Control.Monad.State import Control.Monad.Reader import System.IO import System.Posix.Process (executeFile, forkProcess, getProcessStatus, createSession) +import System.Process +import System.Directory import System.Exit import System.Environment import Graphics.X11.Xlib @@ -281,6 +283,17 @@ restart mprog resume = do catchIO (executeFile prog True args Nothing) where showWs = show . mapLayout show +-- | Recompile ~\/xmonad\/xmonad.hs. +-- +-- Raises an exception if ghc can't be found. +recompile :: IO () +recompile = do + dir <- fmap (++ "/.xmonad") getHomeDirectory + pid <- runProcess "ghc" ["--make", "xmonad.hs"] (Just dir) + Nothing Nothing Nothing Nothing + waitForProcess pid + return () + -- | Run a side effecting action with the current workspace. Like 'when' but whenJust :: Monad m => Maybe a -> (a -> m ()) -> m () whenJust mg f = maybe (return ()) f mg -- cgit v1.2.3