Knowing and customizing shortcuts is the essence of being productive with XMonad. To get some inspiration it’s helpful to look at how built-in and other shortcuts are defined.
In this tutorial we go over some shortcuts for XMonad:
Built-in shortcuts
To avoid needless work and keep our XMonad config file short, we shouldn’t define shortcuts that are already built-in ➡ Cheat sheet. Nevertheless, it’s helpful to see how some of these are defined internally in case we need similar actions:
Built-in shortcut | Action |
---|---|
("M-k", windows focusDown)
|
Move focus to previous window above. |
("M-j", windows focusDown)
|
Move focus to next window below. |
("M-m", windows focusMaster)
|
Move focus to master window of current workspace. |
("M-l", sendMessage Expand)
|
Increase master window space horizontally. |
("M-h", sendMessage Shrink)
|
Decrease master window space horizontally. |
("M-S-c", kill)
|
Close currently focused window. |
("M-1", view "1")
|
Change and show the workspace given by its name/ID. |
("M-<Space>", sendMessage NextLayout)
- Use the next layout arrangement for the windows in your currently visible workspace
("M-S-<Space>", setLayout $ layoutHook myConfig)
- Use the next layout arrangement for the windows in your currently visible workspace
("M-<Enter>", spawn $ terminal myConfig)
- Open an app or run a script.
("M-t", withFocused (windows . W.sink))
- Put a floating window back into your layout arrangement.
("M-S-q", io (exitWith ExitSuccess))
- Close XMonad and log out.
More: In-depth XMonad shortcuts
More: EZ shortcuts
More: Screens, workspaces and windows
See: Default shortcuts source code
Some other useful shortcut examples to know about:
("M-f", spawn "firefox")
- Open the Firefox browser with Mod + f.
("M-S-m", windows swapMaster)
- Swap the current focused non-master window with the master window with Mod + Shift + m.
("M-a w", spawn "firefox -new-instance -p \"web\"")
- Open a Firefox app instance for web stuff with Mod + a and then w.
("M-a S-w", spawn "firefox -new-instance -p \"work\"")
- Open a separate Firefox app instance just for work with Mod + a and then Shift + w.
("M-a e", spawn "thunderbird")
- Open the email app Thunderbird with Mod + a and then e.
Ubuntu specific shortcuts
("M-d v", spawn "nautilus ~/Videos/")
- Open the directory “Videos” in the Nautilus file manager with Mod + d and then v.
("<XF86AudioMute>", spawn "amixer -D pulse set Master 1+ toggle")
- Mute sound with the “Mute” multimedia key
("<XF86AudioLowerVolume>", spawn "amixer -D pulse set Master 10%-")
- Decrease volume with the “LowerVolume” multimedia key
("<XF86AudioRaiseVolume>", spawn "amixer -D pulse set Master 10%+")
- Increase volume with the “RaiseVolume” multimedia key
("M-<Escape> l", spawn "dm-tool lock")
- Lock your Ubuntu session and ask for password to continue working with Mod + Esc and then l.
("M-o 0", spawn "xrandr --output eDP-1 --auto --output HDMI-1 --auto --right-of eDP-1")
- Enable using two screens with Mod + o and then 0.
("M-o 1", spawn "xrandr --output eDP-1 --auto --output HDMI-1 --off --right-of eDP-1")
- Enable using only the first of two screens with Mod + o and then 1.
("M-o 2", spawn "xrandr --output eDP-1 --off --output HDMI-1 --auto --right-of eDP-1")
- Enable using only the second of two screens with Mod + o and then 2.
Ubuntu and other linux distributions may have problems with sound or screen controls. In that case we can run lower-level commands ourselves, bypassing the distribution’s apps. For example. the terminal app amixer
allows us to set your sound setting via the commandline and is an alternative to a graphical sound settings window. Similarly, the terminal app xrandr
allows us to set up and control multiple monitors via the commandline.
More: In-depth XMonad shortcuts
See: List of all multimedia keys
More: EZ shortcuts
More: How to use Amixer
More: How to use Xrandr