Installing XMonad

!! ( watch video after install for configuration tips ) !!

XMonad install on Void Linux in 2025: A Step-by-Step Guide

XMonad, a lightweight and highly customizable tiling window manager written in Haskell, is a favorite among Linux enthusiasts who crave efficiency and control over their desktop environment. However, if you’re running Void Linux—a unique, independent distribution known for its minimalist philosophy and rolling-release updates—you might have noticed that XMonad is no longer available as a pre-built package in the official Void repositories as of February 2025. Don’t worry, though! You can still install and enjoy XMonad using Haskell’s package manager, Cabal. In this guide, I’ll walk you through the process of installing XMonad on Void Linux, step by step, ensuring you have a fully functional setup tailored to your needs.

Prerequisites

Before diving into the XMonad installation, you’ll need a working X server since XMonad relies on it to manage your windows. If you haven’t set up X yet, install the essentials with Void’s XBPS package manager:

sudo xbps-install -S xorg-minimal xterm
  • xorg-minimal: Provides the core X server components.
  • xterm: A simple terminal emulator to interact with XMonad initially.

With these in place, let’s get started.

Step 1: Install Dependencies

Since XMonad is no longer in the Void repositories, we’ll build it from source using Cabal. This requires some Haskell tools and X11 development libraries. Install them with:

sudo xbps-install -S git cabal-install ghc libX11-devel libXft-devel libXinerama-devel libXrandr-devel libXScrnSaver-devel pkg-config

Here’s what each package does:

  • git: Useful if you need to clone XMonad’s source manually (though Cabal handles this for us).
  • cabal-install and ghc: The Haskell package manager and compiler, respectively.
  • libX*-devel: Development libraries for X11, necessary for building XMonad.

Step 2: Install XMonad via Cabal

Cabal makes it straightforward to fetch and build XMonad from Hackage, the Haskell package repository. Follow these steps:

Update Cabal to ensure you’re working with the latest package list:

cabal update

Install XMonad and its Contrib Library:

cabal install --lib xmonad xmonad-contrib X11
cabal install xmonad
  • The --lib flag installs the libraries needed for custom configurations.
  • The second command builds and installs the xmonad binary to ~/.cabal/bin/.

Add Cabal’s Bin Directory to Your PATH

To run XMonad from anywhere, add ~/.cabal/bin to your shell’s PATH. Edit your shell config file (e.g., ~/.bashrc or ~/.zshrc):

export PATH="$HOME/.cabal/bin:$PATH"

Apply the change:

source ~/.bashrc

Step 3: Configure XMonad

XMonad’s power lies in its configurability, managed through a Haskell file at ~/.xmonad/xmonad.hs. Create a basic configuration:

mkdir -p ~/.xmonad
cat > ~/.xmonad/xmonad.hs << EOF
import XMonad

main :: IO ()
main = xmonad =<< xmobar myConfig

myConfig = def {
    -- Customize here, e.g., set your preferred terminal
    terminal = "xterm"
}
EOF
  • This sets up XMonad with default settings and xterm as the terminal.
  • The xmobar integration is optional; we’ll cover it later if you want a status bar.

Step 4: Set Up XMonad to Start

You can launch XMonad manually via .xinitrc or integrate it with a display manager. Here are both options:

Option 1: Using .xinitrc (Manual Start)

Create or edit ~/.xinitrc:

echo "exec xmonad" > ~/.xinitrc

Start X with:

startx

Option 2: Using a Display Manager (e.g., LightDM)

For a graphical login:

Install sddm if you don’t have it:

sudo xbps-install -S sddm
sudo ln -s /etc/sv/sddm /var/service/

Create an XMonad session file:

sudo mkdir -p /usr/share/xsessions
sudo tee /usr/share/xsessions/xmonad.desktop > /dev/null << EOF
[Desktop Entry]
Name=XMonad
Comment=Lightweight tiling window manager
Exec=dbus-launch /home/<user>/.cabal/bin/xmonad
Type=Application
EOF

Replace user with your actual username. Log out, and select “XMonad” from LightDM’s session menu.

Step 5: Test and Troubleshoot

  • Recompile your config to catch errors:
xmonad --recompile

If it fails, double-check your dependencies and xmonad.hs syntax.

  • Test by pressing Mod+Shift+Enter (default Mod is Alt) to open a terminal. If it doesn’t work, ensure xterm is installed and the xmonad binary is accessible.

Choosing a Status Bar

XMonad does not come with a built-in status bar, so you will need to install and configure one separately. There are several options to choose from, each with different features and levels of customization:

  • xmobar: A lightweight and simple status bar written in Haskell, designed to integrate well with XMonad.
  • polybar: A more feature-rich and customizable bar that supports modules, system info, and various widgets.
  • tint2: A flexible and lightweight panel that works well with multiple window managers.
  • lemonbar: A minimal and scriptable bar, suitable for advanced users who want full control over their setup.
  • dzen2: A scriptable status bar that allows for custom formatting and data display.

To install one of these bars, use xbps-install. For example, to install polybar:

sudo xbps-install -S polybar

Once installed, you will need to configure your chosen bar and integrate it with your xmonad.hs configuration.

Final Notes

Void Linux’s rolling-release model means package availability can shift, but installing XMonad via Cabal keeps you up-to-date as of February 23, 2025. If Cabal gives you trouble, consider using Stack (sudo xbps-install -S stack, then stack install xmonad xmonad-contrib) or check the XMonad documentation for the latest tips.

You’re now ready to enjoy XMonad’s tiling goodness on Void Linux. Happy hacking!