xmonad-contrib-0.12: Third party extensions for xmonad

Copyright(c) Peter J. Jones
LicenseBSD3-style (see LICENSE)
MaintainerPeter Jones <pjones@devalot.com>
Portabilitynot portable
Safe HaskellNone




Imbues workspaces with additional features so they can be treated as individual project areas.



Inspired by TopicSpace, DynamicWorkspaces, and WorkspaceDir, DynamicProjects treats workspaces as projects while maintaining compatibility with all existing workspace-related functionality in XMonad.

Instead of using generic workspace names such as 3 or work, DynamicProjects allows you to dedicate workspaces to specific projects and then switch between projects easily.

A project is made up of a name, working directory, and a start-up hook. When you switch to a workspace, DynamicProjects changes the working directory to the one configured for the matching project. If the workspace doesn't have any windows, the project's start-up hook is executed. This allows you to launch applications or further configure the workspace/project.

When using the switchProjectPrompt function, workspaces are created as needed. This means you can create new project spaces (and therefore workspaces) on the fly. (These dynamic projects are not preserved across restarts.)

Additionally, frequently used projects can be configured statically in your XMonad configuration. Doing so allows you to configure the per-project start-up hook.


To use DynamicProjects you need to add it to your XMonad configuration and then configure some optional key bindings.

import XMonad.Actions.DynamicProjects

Start by defining some projects:

projects :: [Project]
projects =
  [ Project { projectName      = "scratch"
            , projectDirectory = "~/"
            , projectStartHook = Nothing

  , Project { projectName      = "browser"
            , projectDirectory = "~/download"
            , projectStartHook = Just $ do spawn "conkeror"
                                           spawn "chromium"

Then inject DynamicProjects into your XMonad configuration:

main = xmonad $ dynamicProjects projects def

And finally, configure some optional key bindings:

 , ((modm, xK_space), switchProjectPrompt)
 , ((modm, xK_slash), shiftToProjectPrompt)

For detailed instructions on editing your key bindings, see XMonad.Doc.Extending.


data Project Source

Details about a workspace that represents a project.




projectName :: !ProjectName

Workspace name.

projectDirectory :: !FilePath

Working directory.

projectStartHook :: !(Maybe (X ()))

Optional start-up hook.


dynamicProjects :: [Project] -> XConfig a -> XConfig a Source

Add dynamic projects support to the given config.


switchProjectPrompt :: XPConfig -> X () Source

Prompt for a project name and then switch to it. Automatically creates a project if a new name is returned from the prompt.

shiftToProjectPrompt :: XPConfig -> X () Source

Prompts for a project name and then shifts the currently focused window to that project.

renameProjectPrompt :: XPConfig -> X () Source

Rename the current project.

Helper Functions

switchProject :: Project -> X () Source

Switch to the given project.

shiftToProject :: Project -> X () Source

Shift the currently focused window to the given project.

lookupProject :: ProjectName -> X (Maybe Project) Source

Find a project based on its name.

currentProject :: X Project Source

Fetch the current project (the one being used for the currently active workspace).

activateProject :: Project -> X () Source

Activate a project by updating the working directory and possibly running its start-up hook. This function is automatically invoked when the workspace changes.