summaryrefslogtreecommitdiffstats
path: root/tv/2configs/xserver/xmonad/Util/Shutdown.hs
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2015-10-31 00:13:32 +0100
committerlassulus <lass@aidsballs.de>2015-10-31 00:13:32 +0100
commit5b4a34062462311973bb1798fe3e4538e6eb5706 (patch)
tree31ac952feeb3f534b57fc48c6ae2f71795be2f43 /tv/2configs/xserver/xmonad/Util/Shutdown.hs
parent611f8ef25b4c3984f2f7de7362c4869d1f2f124f (diff)
parentbcaf3771d9503f1b0d01a2c15ca0712ee454342f (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'tv/2configs/xserver/xmonad/Util/Shutdown.hs')
-rw-r--r--tv/2configs/xserver/xmonad/Util/Shutdown.hs53
1 files changed, 0 insertions, 53 deletions
diff --git a/tv/2configs/xserver/xmonad/Util/Shutdown.hs b/tv/2configs/xserver/xmonad/Util/Shutdown.hs
deleted file mode 100644
index c5a3edb80..000000000
--- a/tv/2configs/xserver/xmonad/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 (concatMap (++"\n") s)
- exitSuccess
- return ()