Created
April 15, 2019 22:34
-
-
Save dmwit/2a24ab10d8ef274669fec54399defe33 to your computer and use it in GitHub Desktop.
how to xmonad graceful exit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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