xmonad(1) OverviewAaron Poffenberger
As noted above, all features of xmonad(1) are accessible from the keyboard.1 The first thing to know, then, is how to do that. xmonad functions are typically accessed by key bindings using the mod key. On PC computers this is usually the Alt key, on Macintosh computers this is the key labeled Opt with the word Alt printed above in smaller letters.
To get started, there are few key binding you must know:
mod-shift-slash Run xmessage(1) with a summary of the default keybindings (useful for beginners)
mod-shift-return launches a terminal window
mod-shift-c closes the current window
mod-q restarts xmonad (reloading settings)
mod-shift-q quits xmonad (returning to the login screen)
mod-shift-space returns to the default window layout
mod-space rotates through the window layouts
mod-tab moves focus to the next window
Remember that all keys must be pressed at the same time for the action to take effect. To prevent stray keystrokes, always type the commands as printed, left-to-right. E.g., mod-shift-space should be pressed as mod, then shift then space.2
The xmonad man page lists the default key bindings. Type
man xmonad in the terminal to see them. Or, as noted above, mod-shift-slash (forward slash) will open xmessage(1) in a graphical window with all the defaults.
Other commands can be bound to key strokes but must be added to the xmonad.hs configuration file.
Menus and Application Launching
By default xmonad has no menu bar. It does, however, integrate well with dmenu(1) and gmrun. mod-p launches dmenu_run which appears at the top of the screen. You can then launch a program by typing it's name. dmenu_run will progressively filter the list of available programs as you type. Hit tab to complete names, enter at any time to launch the program currently listed.
gmrun works similarly but launches a small window over the main screen. mod-shift-p launches gmrun. gmrun does not progressively filter but it does offer tab completion.
Working with Windows
xmonad is a tiling window manager meaning that windows do not float above, below or next-to one another. They are typically docked above or next to one another.
xmonad distinguishes between the master window and the other windows. To make another window the master window, switch to that window by pressing mod-tab until the light-red highlight surrounds the window. Press mod-shift-enter to make it the master.
To change the the mode press mod-space. The default in xmonad is to shift from Tall to Tall Mirror which stacks the master window over the other windows.
After Tall Mirror xmonad will switch to Full which places the other windows behind the master window and gives it full focus on the screen.
Windows can be resized when in one of the multi-window layouts. Press mod-l to increase the size of the master window. Press mod-h to decrease the size of the master window. And press mod-shift-space to return to the default layout and sizes.
Working with Workspaces
Like many window managers, xmonad has multiple workspaces; nine to be precise. Workspaces, or virtual desktops as they're known in other window managers, make it easy for users to aggregate common applications and tasks.
To switch between workspaces in xmonad press mod-[1-9]. That is, press mod-2 to switch to workspace 2, mod-3 switch to workspace 3. xmonad always launches in workspace 1.
Moving Windows to Other Workspaces
When in a workspace, any programs the user launches will launch in that workspace. To move a window from one workspace to another, select the window first with alt-tab and then press mod-shift-[1-9]. That is, to move the selected window to workspace 3, press mod-shift-3. The window will disappear and now can be seen by switching to the workspace.
xmonad will work with status bars. A popular one is xmobar. xmobar is written in Haskell but does not require any knowledge of Haskell to configure. Rather xmobar is configured via an rc file in the user's home directory.
However, to integrating xmobar into xmonad will require a little Haskell.
A Simple xmonad.hs
To add features or make changes to xmonad does not always require changes to the xmonad itself. Many configuration changes can be made by creating an xmonad.hs file in the ~/.xmonad directory.
Following is a simple xmonad.hs file that launches xmobar.
import XMonad import XMonad.Hooks.DynamicLog main = xmonad =<< xmobar defaultConfig
To use the file, make sure it's in your user directory.
mkdir ~/.xmonad # using your favorite editor, add the lines above # emacs ~/.xmonad/xmonad.hs # copy the lines above # save xmonad --recompile xmonad --restart
After a few moments, xmobar should start up in its default configuration.
To learn more about xmonad see:
- xmonad tutorial
- Beginner's Guide to Xmonad
- How to Use Xmonad, a Tiling Window Manager for Linux
- Xmonad on the Haskell Wiki
Remember, commands listed with a parentheses after them indicate a man page is available. Type
man [number] commandwhere [number] indicates the number in the brackets. It's not always required but some commands appear in more than one section of man and the number makes clear which one we mean.↩
*mod* and shift can be pressed in any order but for the sake of consistency I'll document them in the order printed in the man pages.↩