[xmonad] Re: Issue 347 in xmonad: Feature request: Adding new Topics as you go

codesite-noreply at google.com codesite-noreply at google.com
Fri May 21 05:45:44 EDT 2010


Comment #4 on issue 347 by loupgaroublond: Feature request: Adding new  
Topics as you go
http://code.google.com/p/xmonad/issues/detail?id=347

'lo,

I've worked out a similar solution, let me show you some code:

-- Workspaces

_spaces = M.fromList $
           [ ("schutbord", "~")
           , ("browsen", "~")
           , ("praten", "~")
           , ("muziek", "~/Muziek")
           , ("berichten", "~/Mail")
           , ("agenda", "~/Documenten/Day Planner")
           , ("ldap", "~")
           , ("flim", "~")
           , ("terminals", "~")
           ]

_workspaces = [ "schutbord"]

_topicConfig = TS.TopicConfig {
                  TS.topicDirs = _spaces
                , TS.topicActions = _topicActions
                , TS.defaultTopicAction = (const $ return ())
                , TS.defaultTopic = "schutbord"
                , TS.maxTopicHistory = 10
                }

_topicActions = M.fromList $
                 [ ("schutbord", replicateM_ 2 runColourTerminal)
                 , ("terminals", replicateM_ 2 runColourTerminal)
                 , ("browsen", runBrowser)
                 , ("praten", runChat)
                 , ("berichten", runMail)
                 , ("muziek", runMixer >> runMusicPlayer)
                 , ("transmission", runTorrent)
                 , ("agenda", runEditor)
                 , ("flim", runFilm)
                 ]

goto :: TS.Topic -> X ()
goto t = newWorkspace t >> TS.switchTopic _topicConfig t

shift = windows . W.shift

newWorkspace :: WorkspaceId -> X ()
newWorkspace w = do exists <- widExist w
                     if (not exists) then DW.addHiddenWorkspace w else  
return ()

newWorkspaceDir :: WorkspaceId -> X ()
newWorkspaceDir w = do exists <- widExist w
                        if (not exists)
                            then do DW.addHiddenWorkspace w
                                    goto w
                                    WD.changeDir P.defaultXPConfig
                            else return ()

widExist :: WorkspaceId -> X Bool
widExist wid = do xs <- get
                   return $ widExists wid ( windowset xs )

widExists :: WorkspaceId -> W.StackSet WorkspaceId l a s sd -> Bool
widExists wid ws = wid `elem` map W.tag  (W.workspaces ws)

I also have these key bindings (with ezconfig)

               , ("M-S-n", PI.inputPrompt P.defaultXPConfig "New Workspace:"  
PI.?+
newWorkspaceDir)
               , ("M-S-<Backspace>", WithAll.killAll >> DW.removeWorkspace)
               , ("M-S-r", DW.renameWorkspace P.defaultXPConfig)
               [ -- Applications
                 ("M-t", goto "terminals")
               , ("M-S-t", runColourTerminal)
               , ("M-v M-t", pasteTerminal)
               , ("M-v M-d", manTerminal)
               , ("M-i", goto "browsen")
               , ("M-S-i", runBrowser)
               , ("M-v M-i", pasteBrowser)
               , ("M-p", runCmdLine)
               , ("M-x", WD.changeDir P.defaultXPConfig)
               , ("M-e", goto "muziek")
               -- , ("M-o", runMixer)
               , ("M-h", runFileManager)
               , ("M-s", goto "praten")
               , ("M-m", goto "berichten")
               , ("M-S-m", runMail)
               , ("M-u", goto "agenda")
               , ("M-0", goto "schutbord")
               , ("M-w", goto "flim")




More information about the xmonad mailing list