Installing XMonad in Arch Linux using Cabal

We are going to install XMonad in Arch Linux using Cabal from Hackage (Package repository for Haskell). There is already xmonad package but still we are using hackage because in Arch Linux we may get dependencies problems.

To begin we need to install ghcup first.

curl --proto '=https' --tlsv1.2 -sSf | sh

ghcup is a tool to install all necessary packages to begin with Haskell. Install cabal and all other tool you think you may need. If you don’t know what else you need install everything with ghcup.

While installing ghcup will automatically add path to your active shell. Remember this we need it later.

Now you have cabal installed, so install xmonad, xmonad-contrib and xmobar.

cabal install --lib xmonad
cabal install --lib xmonad-contrib
cabal install xmobar --flags="all_extensions" --overwrite-policy=always

Next step is to make xmonad start and appear in our Display Manager. We are going to use xinit to start the Xorg display server. xinit has its default behavior and config so we need to first copy the default xinitrc in our home directory. If you are already using xinit before you may be already know what you are going to do here.

cp /etc/X11/xinit/xinitrc ~/.xinitrc

At last there are some line which will execute Twm, xorg-xclock and Xterm. We need to remove these and add our own programs and xmonad. For example if we need to run <a href="">nitrogen</a> also then we may have config like:

nitrogen --restore &
exec xmonad

But wait xmonad will not execute from here because we have not added xmonad bin in our path. When installing ghcup you may have been asked to add path in you shell. Copy that line from your shell config before exec xmonad. If you don’t have it you can manually add like this:

# srouce ghcup-env so that xmonad can be found
[ -f "/home/user_name/.ghcup/env" ] && source "/home/user_name/.ghcup/env" # ghcup-env
nitrogen --restore &
exec xmonad

After this we need to make it able to start session from Display Manager. For this install xnint-xsession from AUR.

Packages that you may want to use:

stalonetray, dunst, nitrogen, blueman, mictray, network-manager-applet, redshift, perl-file-mimeinfo

Now you are all done. Logout, then you can find xinitrc session in you display manager. You can find my dotfiles here

This Post Has One Comment

  1. Ahmad

    You share very informative knowledge with us.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.