From a fresh installation of Ubuntu 20.04 (ubuntu-20.04.2.0-desktop-amd64.iso
), install the base XMonad package, extra libraries/modules from the community as well as xterm
and dmenu
with:
sudo apt install xmonad libghc-xmonad-contrib-dev xterm dmenu
Log out, click your user, select XMonad
from the cog at the bottom right and type your password to log in using XMonad instead of the default window manager. The black screen you get is suckless to the extreme and completely expected :-) No wallpaper, no menu, no panel...
The default keybindings in XMonad are:
Mod+Shift+Enter
to open a terminal (GNOME Terminal
by default)Mod+p
fordmenu
Mod+Shift+c
to close a windowMod+j
andMod+k
to shift focus between windowsMod+Space
to cycle through the layoutsMod+Shift+q
to exit XMonad and logout
with Mod
hardcoded as Alt
(Cmd
on Keychron configured as Win/Android) until we change it later.
Launch Firefox with dmenu
(Mod+p
). Google xmonad config archive
, go to the first result and download the latest darcs template xmonad.hs from code.haskell.org. Alternatively, downloat it from a terminal (Mod+Shift+Enter
):
sudo apt install curl
curl -L http://code.haskell.org/xmonad/man/xmonad.hs -o ~/.xmonad/xmonad.hs
Edit the file with vim ~/.xmonad/xmonad.hs
and update some settings. For example:
myTerminal = "gnome-terminal"
myBorderWidth = 2
myModMask = mod4Mask -- mod1Mask = Alt, mod4Mask = Super/Windows
Type :w
to save the changes, then restart XMonad with Alt+q
. The border around the window should get thicker, and Super/Windows
is now the Mod
key in case you decided to change it. If so, Super+Shift+Enter
should bring up gnome-terminal
and Super+Shift+c
should close it.
Update myStartupHook
to change the wallpaper and set transparency with a composer like compton
each time XMonad starts or is restarted
myStartupHook = do
spawnOnce "nitrogen --restore &" -- set wallpaper
spawnOnce "compton &" -- set transparency
Type :w
to save the changes, then install nitrogen
and compton
from a terminal (Mod+Shift+Enter
) with sudo apt install compton nitrogen
. Close the terminal with Mod+Shift+c
then restart XMonad with Mod+q
and confirm you get an import error. Type gg
to go to the top of the file, then add import XMonad.Util.SpawnOnce
after System.Exit
. Hit Mod+q
to restart XMonad and everything should be fine.
Run nitrogen
with Mod+p
. Go to Preferences > Add > /usr/share/backgrounds > Select > OK, select a wallpaper and finally click Apply. Use Mod+Shift+c
to close nitrogen
and other windows, and confirm the wallpaper is set.
Now sudo apt install xmobar
to get a panel that works with XMonad out of the box. Locate a sample config and copy it with:
sudo find / -iname xmobar # /usr/share/docs/xmobar
mkdir /.config/xmobar
cp /usr/share/docs/xmobar/examples/xmobar.config ~/.config/xmobar/xmobarrc
Edit xmonad.hs
so Xmobar gets launched each time XMonad is launched. Replace main = xmonad defaults
with:
main = do
xmproc <- spawnPipe "xmobar -x 0 ~/.config/xmobar/xmobarrc" -- launch on monitor 1
xmonad defaults
Add import XMonad.Util.Run
at the top of the file, type :w
to save the changes and Mod+q
to restart XMonad. Xmobar should be running, except the terminal is hiding it. Confirm with Mod+2
to go to the second workspace. XMobar should be visible at the top.
Google xmonad managedocks
to understand how to prevent windows from overlapping this way. Add import XMonad.Hooks.ManageDocks
at the top of the file then replace xmonad defaults
in main
with xmonad $ docks defaults
. Also replace myLayout = ...
with myLayout = avoidStruts (...)
. Finally, confirm that Xmobar is not hidden by the terminal after XMonad gets restarted with Mod+q
.
Finally, edit the Xmobar config with vim ~/.config/xmobar/xmobarrc
and update a few settings, for example the font with:
font = "xft:Ubuntu Mono:pixelsize=16:antialiasing=true:hinting=true"
Note that you might need to killall xmobar
before Mod+q
, so existing Xmobar instances do not prevent the new one from showing up correctly.
- Getting Started with XMoad by DistroTube