mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-15 20:23:55 -07:00
make WorkspaceDir always store absolute pathnames.
This commit is contained in:
@@ -29,7 +29,7 @@ module XMonad.Layout.WorkspaceDir (
|
|||||||
changeDir
|
changeDir
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import System.Directory ( setCurrentDirectory )
|
import System.Directory ( setCurrentDirectory, getCurrentDirectory )
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Operations ( sendMessage )
|
import XMonad.Operations ( sendMessage )
|
||||||
@@ -63,13 +63,18 @@ data WorkspaceDir a = WorkspaceDir String deriving ( Read, Show )
|
|||||||
|
|
||||||
instance LayoutModifier WorkspaceDir a where
|
instance LayoutModifier WorkspaceDir a where
|
||||||
hook (WorkspaceDir s) = scd s
|
hook (WorkspaceDir s) = scd s
|
||||||
handleMess (WorkspaceDir _) m = return $ do Chdir wd <- fromMessage m
|
handleMess (WorkspaceDir _) m
|
||||||
Just (WorkspaceDir wd)
|
| Just (Chdir wd) <- fromMessage m = do wd' <- cleanDir wd
|
||||||
|
return $ Just $ WorkspaceDir wd'
|
||||||
|
| otherwise = return Nothing
|
||||||
|
|
||||||
workspaceDir :: LayoutClass l a => String -> l a
|
workspaceDir :: LayoutClass l a => String -> l a
|
||||||
-> ModifiedLayout WorkspaceDir l a
|
-> ModifiedLayout WorkspaceDir l a
|
||||||
workspaceDir s = ModifiedLayout (WorkspaceDir s)
|
workspaceDir s = ModifiedLayout (WorkspaceDir s)
|
||||||
|
|
||||||
|
cleanDir :: String -> X String
|
||||||
|
cleanDir x = scd x >> io getCurrentDirectory
|
||||||
|
|
||||||
scd :: String -> X ()
|
scd :: String -> X ()
|
||||||
scd x = do x' <- io (runProcessWithInput "bash" [] ("echo -n " ++ x) `catch` \_ -> return x)
|
scd x = do x' <- io (runProcessWithInput "bash" [] ("echo -n " ++ x) `catch` \_ -> return x)
|
||||||
catchIO $ setCurrentDirectory x'
|
catchIO $ setCurrentDirectory x'
|
||||||
|
Reference in New Issue
Block a user