diff options
author | David Roundy <droundy@darcs.net> | 2007-11-01 22:44:01 +0100 |
---|---|---|
committer | David Roundy <droundy@darcs.net> | 2007-11-01 22:44:01 +0100 |
commit | ba10ee3ef635efd56f35e3aa937059c712b207d0 (patch) | |
tree | aa76ee17ced28c25acdf7108431133937073275d | |
parent | 256f9ae64edf824f1174249a725d6f0a20f46667 (diff) | |
download | XMonadContrib-ba10ee3ef635efd56f35e3aa937059c712b207d0.tar.gz XMonadContrib-ba10ee3ef635efd56f35e3aa937059c712b207d0.tar.xz XMonadContrib-ba10ee3ef635efd56f35e3aa937059c712b207d0.zip |
make WorkspaceDir always store absolute pathnames.
darcs-hash:20071101214401-72aca-20dced2879db31323ad0d8eebab56c8f9b368f0d.gz
-rw-r--r-- | XMonad/Layout/WorkspaceDir.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/XMonad/Layout/WorkspaceDir.hs b/XMonad/Layout/WorkspaceDir.hs index e5f15ce..a5dbea4 100644 --- a/XMonad/Layout/WorkspaceDir.hs +++ b/XMonad/Layout/WorkspaceDir.hs @@ -29,7 +29,7 @@ module XMonad.Layout.WorkspaceDir ( changeDir ) where -import System.Directory ( setCurrentDirectory ) +import System.Directory ( setCurrentDirectory, getCurrentDirectory ) import XMonad import XMonad.Operations ( sendMessage ) @@ -63,13 +63,18 @@ data WorkspaceDir a = WorkspaceDir String deriving ( Read, Show ) instance LayoutModifier WorkspaceDir a where hook (WorkspaceDir s) = scd s - handleMess (WorkspaceDir _) m = return $ do Chdir wd <- fromMessage m - Just (WorkspaceDir wd) + handleMess (WorkspaceDir _) m + | Just (Chdir wd) <- fromMessage m = do wd' <- cleanDir wd + return $ Just $ WorkspaceDir wd' + | otherwise = return Nothing workspaceDir :: LayoutClass l a => String -> l a -> ModifiedLayout WorkspaceDir l a workspaceDir s = ModifiedLayout (WorkspaceDir s) +cleanDir :: String -> X String +cleanDir x = scd x >> io getCurrentDirectory + scd :: String -> X () scd x = do x' <- io (runProcessWithInput "bash" [] ("echo -n " ++ x) `catch` \_ -> return x) catchIO $ setCurrentDirectory x' |