summaryrefslogtreecommitdiffstats
path: root/tv/2configs/xserver/xmonad
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-10-28 21:00:29 +0100
committertv <tv@shackspace.de>2015-10-28 21:00:29 +0100
commit057c4836c10eebf3141d7b20a9e942518357606c (patch)
treecf3a178377e08c66024a5cbca10266686625bb1e /tv/2configs/xserver/xmonad
parent737922a20e1b15ef5a8d11956c9395f7fede735c (diff)
tv xmonad: resume by reading state from file
Diffstat (limited to 'tv/2configs/xserver/xmonad')
-rw-r--r--tv/2configs/xserver/xmonad/Main.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs
index cc958155e..fe7304904 100644
--- a/tv/2configs/xserver/xmonad/Main.hs
+++ b/tv/2configs/xserver/xmonad/Main.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveDataTypeable #-} -- for XS
+{-# LANGUAGE FlexibleContexts #-} -- for xmonad'
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
@@ -8,7 +9,7 @@ module Main where
import Control.Exception
import Text.Read (readEither)
import XMonad
-import System.Environment (getArgs, getEnv, getEnvironment)
+import System.Environment (getArgs, withArgs, getEnv, getEnvironment)
import System.Posix.Process (executeFile)
import XMonad.Prompt (defaultXPConfig)
import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace
@@ -56,7 +57,7 @@ main = getArgs >>= \case
mainNoArgs :: IO ()
mainNoArgs = do
workspaces0 <- getWorkspaces0
- xmonad
+ xmonad'
-- $ withUrgencyHookC dzenUrgencyHook { args = ["-bg", "magenta", "-fg", "magenta", "-h", "2"], duration = 500000 }
-- urgencyConfig { remindWhen = Every 1 }
-- $ withUrgencyHook borderUrgencyHook "magenta"
@@ -82,6 +83,17 @@ mainNoArgs = do
(FixedColumn 1 20 80 10 ||| Full)
+xmonad' :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO ()
+xmonad' conf = do
+ path <- getEnv "XMONAD_STATE"
+ try (readFile path) >>= \case
+ Right content -> do
+ putStrLn ("resuming from " ++ path)
+ withArgs ("--resume" : lines content) (xmonad conf)
+ Left e -> do
+ putStrLn (displaySomeException e)
+ xmonad conf
+
getWorkspaces0 :: IO [String]
getWorkspaces0 =
try (getEnv "XMONAD_WORKSPACES0_FILE") >>= \case