Install Spectrwm, a small dynamic TWM for X11

After installing Arch Linux, you may want to add some features to your installation and become more productive. To do this we are going to see how to install Spectrwm, a small dynamic tiling window manager. TWM is an approach to organize windows without stacking them. The main advantage of using this type of window manager is that it increases productivity (you almost no longer need to use the mouse because everything is done via keyboard shortcuts) and improves workflow.

Update the system

yay -Syyuu

Clone my dotfiles

My configuration files (dotfiles) are available for free. Clone them in your home directory.

git clone

Install required packages

Some explanations about the packages that are going to be installed:

yay -S spectrwm fish openssh rofi xorg xorg-server scrot xorg-xinit alacritty ranger feh nerd-fonts-complete xf86-video-intel librewolf-bin cifs-utils pulseaudio-alsa pulseaudio-ctl slock xautolock zip unzip alsa-utils redshift-minimal numlockx usbutils netctl dhcpcd

X11 configurations

The xinit program allows a user to manually start an Xorg display server. The startx script is a front-end for xinit.

sudo cp /etc/X11/xinit/xinitrc ~/.xinitrc
sudo chown $(whoami):users ~/.xinitrc

The following thing will be explained later.

cp ~/dotfiles/.fehbg ~/.fehbg

Now we can get the lines that don’t need to be there.

sed -i "/twm*/d" ~/.xinitrc
sed -i "/xclock*/d" ~/.xinitrc
sed -i "/xterm*/d" ~/.xinitrc

Copy the following snippet into ~/.xinitrc. If you don’t have a French keyboard, modify fr with your country code. Finally, replace <username> with your own username.

/usr/bin/setxkbmap fr
/usr/bin/xautolock -time 3 -locker slock &
exec spectrwm

The xautolock binary will lock your system if no activity is detected during three minutes, by executing slock. Later, we will see the slock configuration.

The script .fehbg sets the desktop wallpaper with the picture located at ~/Pictures/wallpaper.jpg. Create the directory and put the file inside.

You may want to launch Spectrwm once logged to your account? Copy the snippet below to ~/.bash_profile file, otherwise you’d have to run startx every time…

if systemctl -q is-active && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
	exec startx

Spectrwm configurations

The configuration directory of Spectrwm is located at ~/.config/spectrwm/.

mkdir -p ~/.config/spectrwm
cp ~/dotfiles/.config/spectrwm/* ~/.config/spectrwm/

The file:

Keyboard locale and timezone configurations

If your keyboard is the same as mine (French with 104 keys), you can use the following configuration. If not, you can list all variants and options with list-keymaps, list-locales, list-x11-keymap-layouts, list-x11-keymap-models, list-x11-keymap-options or list-x11-keymap-variants.

sudo localectl set-keymap fr
sudo localectl --no-convert set-x11-keymap fr pc104
sudo localectl set-locale LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8
sudo timedatectl set-timezone Europe/Paris

If your timezone is not this one, list all timezones with timedatectl list-timezones.

Block VT switching and prevent killing X11

I recommend that you block VT (Virtual Terminal) switching so that the screen lock cannot be bypassed. For the same reason, slock recommends that you prevent users from killing the X11 server. Copy the following snippet into /etc/X11/xorg.conf.

Section "ServerFlags"
	Option "DontVTSwitch" "True"
	Option "DontZap" "True"

Screen lock configuration

Below, the configuration for slock. Copy the following snippet into /etc/systemd/system/slock@.service

Description=Lock X11 session using slock for user %i

ExecStartPre=/usr/bin/xset dpms force suspend


Enable the slock service. Replace with your own username.

sudo systemctl enable slock@<username>.service

Fix tearing, pixel and text issues

My laptop have an Intel GPU based and I encounter many issues with it. Copy the following snippet into /etc/X11/xorg.conf.d/20-intel.conf to fix these issues.

Section "Device"
	Identifier "Intel Graphics"
	Driver "intel"
	Option "AccelMethod" "sna"
	Option "TearFree" "true"

Alacritty configuration

As for the Spectrwm configuration, the one above fits my requirements. You can adjust the value as you wish.

mkdir ~/.config/alacritty
cp ~/dotfiles/alacritty/alacritty.yml ~/.config/alacritty/alacritty.yml

Rofi configuration

Rofi (with the configuration below) can launch a program (MOD+r) or initiate a SSH connection (MOD+s). The hosts listed in the SSH mode are retrieved from the SSH config file (~/.ssh/config).

mkdir ~/.config/rofi
cp ~/dotfiles/.config/rofi/config ~/.config/rofi/config

Pulseaudio configuration

sudo sed -i "s/autospawn = no/autospawn = yes/" /etc/pulse/client.conf

By doing this, you enable Pulseaudio at boot. So, you can increase or decrease the volume with your keybinding without starting any other program.

Fish configuration

As always, modify the following file according to your preferences.

cp ~/dotfiles/.config/fish/ .config/fish/
mkdir ~/.config/fish/functions
cp ~/dotfiles/.config/fish/functions/* ~/.config/fish/functions/


Mount a Freebox share

If you have a Freebox and you have the NAS feature enabled on it, you can do the following things to access the filesystem.

sudo mkdir -p /mnt/data
sudo mkdir /etc/samba/credentials
sudo chown root:root /etc/samba/credentials

If you have correctly set up your Freebox share, you’ve enabled the authentication (if not, do it now). Create the above file located at /etc/samba/credentials/data and fill your credentials.


Set the correct permissions.

sudo chmod 700 /etc/samba/credentials/
sudo chmod 600 /etc/samba/credentials/data

We’ll use systemd to mount our share, copy the following snippet into /etc/systemd/system/mnt-data.mount. Be careful, the filename mnt-data.mount must correspond to the mount path, in this case /mnt/data.

Description=Freebox share



If you want to mount this share automatically when you want to access it, create the file /etc/systemd/system/mnt-data.automount and put the following content.

Description=Auto mount Freebox share



Enable and start this service.

sudo systemctl enable --now mnt-data.automount

Connect to an access point

You can manage network connections with netctl and profiles. Those profiles are located at /etc/netctl/. The secure way to configure a Wi-Fi connection is to generate a Wi-Fi Protected Access Pre-Shared Key (WPA-PSK) from an ASCII passphrase for a SSID.

wpa_passphrase <SSID>
# reading passphrase from stdin

Now you have your PSK, create a configuration file (called wlanHome for example) and set the following content.

Description="Wi-Fi configuration for home"

For a better understanding, here some explanations:

To start this profile, you must execute the following command.

sudo netctl start wlanHome

Final things

Spectrwm and tools are now configured! Obviously, it is my configuration, you can always modify colors, keybindings by consulting documentation of the concerned tools… Concerning the keybinding, below you’ll find a list to have a quick start (MOD corresponds to the Windows key):

Keep in mind to restart Spectrwm (MOD+Shift+r) after modifying its configuration.