mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-01 12:41:53 -07:00
catch exceptions in spawn, so failing to fork won't kill the wm
This commit is contained in:
@@ -26,6 +26,7 @@ import Control.Monad.State
|
|||||||
import System.IO
|
import System.IO
|
||||||
import System.Process (runCommand)
|
import System.Process (runCommand)
|
||||||
import Graphics.X11.Xlib
|
import Graphics.X11.Xlib
|
||||||
|
import Control.Exception
|
||||||
|
|
||||||
-- | XState, the window manager state.
|
-- | XState, the window manager state.
|
||||||
-- Just the display, width, height and a window list
|
-- Just the display, width, height and a window list
|
||||||
@@ -72,7 +73,8 @@ io = liftIO
|
|||||||
|
|
||||||
-- | spawn. Launch an external application
|
-- | spawn. Launch an external application
|
||||||
spawn :: String -> X ()
|
spawn :: String -> X ()
|
||||||
spawn x = io (runCommand x) >> return ()
|
spawn x = do v <- io $ handle (return . Just) (runCommand x >> return Nothing)
|
||||||
|
whenJust v $ \e -> trace $ "xmonad:spawn: unable to fork "++show x++": "++show e
|
||||||
|
|
||||||
-- | Run a side effecting action with the current workspace. Like 'when' but
|
-- | Run a side effecting action with the current workspace. Like 'when' but
|
||||||
whenJust :: Maybe a -> (a -> X ()) -> X ()
|
whenJust :: Maybe a -> (a -> X ()) -> X ()
|
||||||
|
Reference in New Issue
Block a user