diff options
author | tv <tv@krebsco.de> | 2015-10-28 21:00:29 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2015-10-28 21:00:29 +0100 |
commit | 8f884e8c5071d2a78bc7d24f93c3efbf2762d34e (patch) | |
tree | 491c29587cf0e32c3a008138392d7594c2c94848 /tv/2configs/xserver | |
parent | 47b89bbe4237c4a28bb60a73672426831c142b6d (diff) |
tv xmonad: resume by reading state from file
Diffstat (limited to 'tv/2configs/xserver')
-rw-r--r-- | tv/2configs/xserver/default.nix | 7 | ||||
-rw-r--r-- | tv/2configs/xserver/xmonad/Main.hs | 16 |
2 files changed, 15 insertions, 8 deletions
diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 3ea5cec..388a33b 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -119,12 +119,7 @@ let settle ${pkgs.xorg.xhost}/bin/xhost +LOCAL: settle ${pkgs.xorg.xrdb}/bin/xrdb -merge ${import ./Xresources.nix args} settle ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' - if test -e "$XMONAD_STATE"; then - IFS=''$'\n' - exec ${xmonad-pkg}/bin/xmonad --resume $(< "$XMONAD_STATE") - else - exec ${xmonad-pkg}/bin/xmonad - fi + exec ${xmonad-pkg}/bin/xmonad ''; xmonad-stop = pkgs.writeScriptBin "xmonad-stop" '' diff --git a/tv/2configs/xserver/xmonad/Main.hs b/tv/2configs/xserver/xmonad/Main.hs index cc95815..fe73049 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 |