You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
31 lines
1.1 KiB
10 years ago
|
{-# LANGUAGE DeriveDataTypeable, NoMonomorphismRestriction, MultiParamTypeClasses, ImplicitParams #-}
|
||
|
-------------------------------------------------------------------------------
|
||
|
-- | Allows per workspace working directories
|
||
|
-- ----------------------------------------------------------------------------
|
||
|
|
||
|
module PerWorkspaceDirs (
|
||
|
currentWorkspace
|
||
|
, changeDir
|
||
|
, getDir
|
||
|
) where
|
||
|
|
||
|
import qualified XMonad.Util.ExtensibleState as XS
|
||
|
import XMonad.Core
|
||
|
import XMonad.StackSet (currentTag)
|
||
|
|
||
|
data WorkingDirs = WD [(WorkspaceId, String)] deriving Typeable
|
||
|
|
||
|
instance ExtensionClass WorkingDirs where
|
||
|
initialValue = WD []
|
||
|
|
||
|
changeDir :: String -> WorkspaceId -> X ()
|
||
|
changeDir dir ws = do (WD cdirs) <- XS.get
|
||
|
XS.put . WD $ (ws, dir) : filter (\(a,_) -> a /= ws) cdirs
|
||
|
|
||
|
getDir :: WorkspaceId -> X String
|
||
|
getDir ws = do (WD dirs) <- XS.get
|
||
|
return $ maybe "~/" id (lookup ws dirs)
|
||
|
|
||
|
currentWorkspace :: X WorkspaceId
|
||
|
currentWorkspace = withWindowSet (return . currentTag)
|