summaryrefslogtreecommitdiffstats
path: root/XMonad.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-05-21 21:46:53 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-05-21 21:46:53 +0200
commit43505e3efb39c35f6a34393d1ed3a190f8cc1d85 (patch)
tree5dcfae33fb27543031f66a2643b1aa9e9930dd19 /XMonad.hs
parente6dce1b6b829c593dbc416e1b00efc19b5263008 (diff)
downloadmetatile-43505e3efb39c35f6a34393d1ed3a190f8cc1d85.tar
metatile-43505e3efb39c35f6a34393d1ed3a190f8cc1d85.zip
Experimental support for a beefier restart.
darcs-hash:20070521194653-a5988-b6725cc0d73fc6b726dc41284eef9303a7e59a1e
Diffstat (limited to 'XMonad.hs')
-rw-r--r--XMonad.hs22
1 files changed, 15 insertions, 7 deletions
diff --git a/XMonad.hs b/XMonad.hs
index d18e9f1..dccdd12 100644
--- a/XMonad.hs
+++ b/XMonad.hs
@@ -140,13 +140,21 @@ spawn x = io $ do
getProcessStatus True False pid
return ()
--- | Restart xmonad by exec()'ing self. This doesn't save state and xmonad has
--- to be in PATH for this to work.
-restart :: X ()
-restart = io $ do
- prog <- getProgName
- args <- getArgs
- catch (executeFile prog True args Nothing) (const $ return ())
+-- | Restart xmonad via exec().
+--
+-- If the first parameter is 'Just name', restart will attempt to execute the
+-- program corresponding to 'name'. Otherwise, xmonad will attempt to execute
+-- the name of the current program.
+--
+-- When the second parameter is 'True', xmonad will attempt to resume with the
+-- current window state.
+restart :: Maybe String -> Bool -> X ()
+restart mprog resume = do
+ prog <- maybe (io $ getProgName) return mprog
+ args <- io $ getArgs
+ args' <- if resume then gets (("--resume":) . return . show . windowset) else return []
+ io $ catch (executeFile prog True (args ++ args') Nothing)
+ (const $ return ()) -- ignore executable not found exception
-- | Run a side effecting action with the current workspace. Like 'when' but
whenJust :: Maybe a -> (a -> X ()) -> X ()