diff --git a/src/XMonad/Operations.hs b/src/XMonad/Operations.hs index fedb7192..3c08a676 100644 --- a/src/XMonad/Operations.hs +++ b/src/XMonad/Operations.hs @@ -79,6 +79,7 @@ import qualified Control.Exception as C import System.IO import System.Directory +import System.FilePath ((<.>)) import System.Posix.Process (executeFile) import Graphics.X11.Xlib import Graphics.X11.Xinerama (getScreenInfo) @@ -663,7 +664,9 @@ writeStateToFile = do globalPath <- asks $ stateFileName . directories path <- fromMaybe globalPath <$> sessionStateFileName stateData <- gets (\s -> StateFile (wsData s) (extState s)) - catchIO (writeFile path $ show stateData) + catchIO $ do + writeFile (path <.> "tmp") $ show stateData + renameFile (path <.> "tmp") path -- | Read the state of a previous xmonad instance from a file and -- return that state. The state file is removed after reading it.