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

adrien@archiso ~ $ yay -Syyuu --noconfirm

Clone my dotfiles

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

adrien@archiso ~ $ git clone https://gitea.illuad.fr/adrien/dotfiles.git

Install packages

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

adrien@archiso ~ $ 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 cmatrix yubikey-touch-detector tlp powertop

X11 configurations

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

If you don’t have a French keyboard, modify fr (inside ~/.xinitrc) with your country code. 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.

adrien@archiso ~ $ cp dotfiles/.xinitrc ~/

The script .fehbg sets the desktop wallpaper with the picture located at ~/Pictures/wallpaper.jpg.

adrien@archiso ~ $ mkdir ~/Pictures
adrien@archiso ~ $ cp dotfiles/.fehbg ~/
adrien@archiso ~ $ chmod +x ~/.fehbg

You may want to launch Spectrwm once logged to your account? Copy the following file inside your home directory, otherwise you’d have to run startx every time…

adrien@archiso ~ $ cp dotfiles/.bash_profile ~/

Spectrwm configurations

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

adrien@archiso ~ $ mkdir -p ~/.config/spectrwm
adrien@archiso ~ $ 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.

adrien@archiso ~ $ sudo localectl set-keymap fr
adrien@archiso ~ $ sudo localectl --no-convert set-x11-keymap fr pc104
adrien@archiso ~ $ sudo localectl set-locale LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8
adrien@archiso ~ $ 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.

adrien@archiso ~ $ sudo cp dotfiles/X11/xorg.conf /etc/X11/

Screen lock configuration

Below, the configuration for slock.

adrien@archiso ~ $ sudo cp dotfiles/system/slock@service /etc/systemd/system/slock@.service

Enable the slock service.

adrien@archiso ~ $ sudo systemctl enable slock@$USER

Fix tearing, pixel and text issues

My laptop have an Intel GPU based and I encounter many issues with it.

adrien@archiso ~ $ sudo cp dotfiles/xorg.conf.d/20-intel.conf /etc/X11/xorg.conf.d/

Alacritty configuration

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

adrien@archiso ~ $ mkdir -p ~/.config/alacritty
adrien@archiso ~ $ cp dotfiles/alacritty/alacritty.yml ~/.config/alacritty/

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).

adrien@archiso ~ $ mkdir -p ~/.config/rofi
adrien@archiso ~ $ cp dotfiles/.config/rofi/config ~/.config/rofi/

Pulseaudio configuration

adrien@archiso ~ $ 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.

adrien@archiso ~ $ mkdir -p ~/.config/fish/functions
adrien@archiso ~ $ cp dotfiles/.config/fish/config.fish ~/.config/fish/
adrien@archiso ~ $ cp dotfiles/.config/fish/functions/* ~/.config/fish/functions/

Miscellaneous

Enable numlock during boot

If you have encrypted your disk, during the boot phase you will be asked for the password to decrypt the LUKS partition. If you have a keypad, it is possible that it is not enable. To overcome this “problem”, a package must be installed and hooks modified. Add numlock in the HOOKS section of the /etc/mkinitcpio.conf file. The line concerned should look like the following statement.

adrien@archiso ~ $ yay -S mkinitcpio-numlock
adrien@archiso ~ $ sudo grep HOOKS /etc/mkinitcpio.conf | tail -17
HOOKS=(base udev autodetect numlock modconf block encrypt lvm2 filesystems keyboard fsck)

Load correct keymap during boot

If you have encrypted your disk, during the boot phase you will be asked for the password to decrypt the LUKS partition. If you have a French keyboard, it is possible that it is in QWERTY mode. To overcome this “problem”, the hooks must be modified. Move keyboard and add keymap in the HOOKS section of the /etc/mkinitcpio.conf file. The line concerned should look like the following statement.

adrien@archiso ~ $ sudo grep HOOKS /etc/mkinitcpio.conf | tail -1
adrien@archiso ~ $ HOOKS=(base udev autodetect keyboard keymap numlock modconf block encrypt lvm2 filesystems fsck)

Install missing firmware

During the initramfs’ generation, some WARNING can appears.

==> WARNING: Possibly missing firmware for module: qat_4xxx
==> WARNING: Possibly missing firmware for module: xhci_pci
==> WARNING: Possibly missing firmware for module: wd719x
==> WARNING: Possibly missing firmware for module: aic94xx

Depending your hadware, packages are avaible (simply search the missing module). For me, 3 modules are missing, here is how to install them.

adrien@archiso ~ $ yay -S upd72020x-fw aic94xx-firmware wd719x-firmware

Once this is finished, you can restart the initramfs’ generation.

adrien@archiso ~ $ sudo mkinitcpio -p linux

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.

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.

adrien@archiso ~ $ sudo mkdir -p /mnt/data
adrien@archiso ~ $ sudo mkdir /etc/samba/credentials
adrien@archiso ~ $ sudo cp dotfiles/credentials/data /etc/samba/credentials/
adrien@archiso ~ $ sudo chmod 700 /etc/samba/credentials
adrien@archiso ~ $ sudo chmod 600 /etc/samba/credentials/data

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

adrien@archiso ~ $ sudo cp dotfiles/system/mnt-data.mount /etc/systemd/system/

Copy this file ff you want to mount the share automatically when you access it.

adrien@archiso ~ $ sudo cp dotfiles/system/mnt-data.automount /etc/systemd/system/

Enable and start this service.

adrien@archiso ~ $ 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.

adrien@archiso ~ $ wpa_passphrase <SSID>
# reading passphrase from stdin
<passphrase>

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

Description="Wi-Fi configuration for home"
Interface=wlp2s0
Connection=wireless
Security=wpa
ESSID=<SSID>
IP=dhcp
Key=\"<psk>

For a better understanding, here some explanations:

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

adrien@archiso ~ $ 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.