Skip to content

Instantly share code, notes, and snippets.

@dmwit
Created April 15, 2019 22:34
Show Gist options
  • Save dmwit/2a24ab10d8ef274669fec54399defe33 to your computer and use it in GitHub Desktop.
Save dmwit/2a24ab10d8ef274669fec54399defe33 to your computer and use it in GitHub Desktop.
how to xmonad graceful exit
import Control.Concurrent
import Control.Monad.State
import qualified Data.Map as M
import System.Exit
import XMonad.Core
import XMonad.Operations
import qualified XMonad.StackSet as W
windowIDs :: W.StackSet i l a sid sd -> [a]
windowIDs ss
= goScreen (W.current ss)
++ concatMap goScreen (W.visible ss)
++ concatMap goWorkspace (W.hidden ss)
++ M.keys (W.floating ss)
where
goScreen = goWorkspace . W.workspace
goWorkspace = foldMap goStack . W.stack
goStack s = W.up s ++ [W.focus s] ++ W.down s
gracefulExit :: X ()
gracefulExit = do
ws <- gets windowset
mapM_ killWindow (windowIDs ws)
io (threadDelay 500000) -- adjust to taste, this is 0.5s
io exitSuccess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment