summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs/xmonad-tv/Util/Shutdown.hs
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-11-14 01:50:39 +0100
committermakefu <github@syntax-fehler.de>2015-11-14 01:50:39 +0100
commita0fbe917ac45cda4de0f16bced3ce3ebfc556fe8 (patch)
tree44b66f4c43eeec674dcd763eb50141dd567c35e7 /tv/5pkgs/xmonad-tv/Util/Shutdown.hs
parent79b890670100d08c3640fffade2caf3eced192d8 (diff)
parentebba531273715c1a9c124007b97f3547d16e780f (diff)
Merge remote-tracking branch 'cd/master' into pre-merge
Diffstat (limited to 'tv/5pkgs/xmonad-tv/Util/Shutdown.hs')
-rw-r--r--tv/5pkgs/xmonad-tv/Util/Shutdown.hs53
1 files changed, 0 insertions, 53 deletions
diff --git a/tv/5pkgs/xmonad-tv/Util/Shutdown.hs b/tv/5pkgs/xmonad-tv/Util/Shutdown.hs
deleted file mode 100644
index 89e22b4e7..000000000
--- a/tv/5pkgs/xmonad-tv/Util/Shutdown.hs
+++ /dev/null
@@ -1,53 +0,0 @@
-{-# LANGUAGE LambdaCase #-}
-module Util.Shutdown
- ( sendShutdownEvent
- , handleShutdownEvent
- , shutdown
- )
- where
-
-import Control.Monad
-import Data.Monoid
-import Data.Maybe (catMaybes)
-import qualified Data.Map as Map
-import System.Environment (getEnv)
-import System.Exit (exitSuccess)
-import XMonad
-import qualified XMonad.StackSet as W
-
-sendShutdownEvent :: IO ()
-sendShutdownEvent = do
- dpy <- openDisplay ""
- rw <- rootWindow dpy $ defaultScreen dpy
- a <- internAtom dpy "XMONAD_SHUTDOWN" False
- allocaXEvent $ \e -> do
- setEventType e clientMessage
- setClientMessageEvent e rw a 32 0 currentTime
- sendEvent dpy rw False structureNotifyMask e
- sync dpy False
-
-handleShutdownEvent :: Event -> X All
-handleShutdownEvent = \case
- ClientMessageEvent { ev_message_type = mt } -> do
- c <- (mt ==) <$> getAtom "XMONAD_SHUTDOWN"
- when c shutdown
- return (All c)
- _ ->
- return (All True)
-
-shutdown :: X ()
-shutdown = do
- broadcastMessage ReleaseResources
- io . flush =<< asks display
- let wsData = show . W.mapLayout show . windowset
- maybeShow (t, Right (PersistentExtension ext)) = Just (t, show ext)
- maybeShow (t, Left str) = Just (t, str)
- maybeShow _ = Nothing
- extState =
- return . show . catMaybes . map maybeShow . Map.toList . extensibleState
- s <- gets (\s -> (wsData s : extState s))
- _ <- io $ do
- path <- getEnv "XMONAD_STATE"
- writeFile path (unlines s)
- exitSuccess
- return ()