implement dynamic changing of working directory
This commit is contained in:
parent
6efab03456
commit
cfbc283c3a
1 changed files with 27 additions and 6 deletions
|
@ -6,6 +6,8 @@ module XMonad.Custom.TopicSpace (
|
||||||
, currentTopicConfig
|
, currentTopicConfig
|
||||||
, goto
|
, goto
|
||||||
, spawnInTopicDir
|
, spawnInTopicDir
|
||||||
|
, setTopicDir
|
||||||
|
, promptSetTopicDir
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,12 +45,14 @@ module XMonad.Custom.TopicSpace (
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
|
||||||
-- import qualified Data.Map.Strict as M
|
import Data.Map
|
||||||
import qualified XMonad.Util.ExtensibleState as XS
|
import qualified XMonad.Util.ExtensibleState as XS
|
||||||
-- import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Actions.TopicSpace
|
import XMonad.Actions.TopicSpace
|
||||||
|
import XMonad.Prompt
|
||||||
|
import XMonad.Prompt.Workspace
|
||||||
|
|
||||||
|
|
||||||
-- | An alias for topicNames.
|
-- | An alias for topicNames.
|
||||||
|
@ -84,15 +88,19 @@ instance ExtensionClass StoreTopicConfig where
|
||||||
topicConfig :: StoreTopicConfig -> TopicConfig
|
topicConfig :: StoreTopicConfig -> TopicConfig
|
||||||
topicConfig (StoreTopicConfig tc) = tc
|
topicConfig (StoreTopicConfig tc) = tc
|
||||||
|
|
||||||
-- | Put initial topic Config into X state at startup
|
-- | Update the value of the topic config in the X state
|
||||||
-- Add this to the XConfig startupHook
|
updateTopicConfig :: TopicConfig -> X ()
|
||||||
topicStartupHook :: TopicConfig -> X ()
|
updateTopicConfig = XS.put . StoreTopicConfig
|
||||||
topicStartupHook = XS.put . StoreTopicConfig
|
|
||||||
|
|
||||||
-- | Retrieve the current topic config from the X state
|
-- | Retrieve the current topic config from the X state
|
||||||
currentTopicConfig :: X TopicConfig
|
currentTopicConfig :: X TopicConfig
|
||||||
currentTopicConfig = fmap topicConfig XS.get
|
currentTopicConfig = fmap topicConfig XS.get
|
||||||
|
|
||||||
|
-- | Put initial topic Config into X state at startup
|
||||||
|
-- Add this to the XConfig startupHook
|
||||||
|
topicStartupHook :: TopicConfig -> X ()
|
||||||
|
topicStartupHook = updateTopicConfig
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
-- | These are the real utilities that we aimed for
|
-- | These are the real utilities that we aimed for
|
||||||
|
@ -112,3 +120,16 @@ spawnInTopicDir cmd = do
|
||||||
tc <- currentTopicConfig
|
tc <- currentTopicConfig
|
||||||
dir <- currentTopicDir tc
|
dir <- currentTopicDir tc
|
||||||
spawn $ "cd " ++ dir ++ "; " ++ cmd
|
spawn $ "cd " ++ dir ++ "; " ++ cmd
|
||||||
|
|
||||||
|
-- | Set the working directory of the current topic
|
||||||
|
setTopicDir :: Dir -> X ()
|
||||||
|
setTopicDir dir = do
|
||||||
|
ws <- gets (W.currentTag . windowset)
|
||||||
|
tc <- currentTopicConfig
|
||||||
|
updateTopicConfig tc {
|
||||||
|
topicDirs = insert ws dir $ topicDirs tc
|
||||||
|
}
|
||||||
|
|
||||||
|
-- | Prompt for the new working directory
|
||||||
|
promptSetTopicDir :: XPConfig -> X ()
|
||||||
|
promptSetTopicDir xpc = workspacePrompt xpc setTopicDir
|
||||||
|
|
Loading…
Reference in a new issue