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:
spectrwm
: the small dynamic windows manager for Xorg.fish
: a pretty nice commandline shell.openssh
: SSH tools.rofi
: a window switcher, run dialog, ssh-launcher.xorg
andxorg-*
: open source implementation of the X Window System.scrot
: tool to take screenshot.alacritty
: GPU-accelerated terminal emulator.ranger
: a text-based file manager.feh
: an image viewer and tool to manage the desktop wallpaper.nerd-fonts-complete
: set of fonts and icons.xf86-video-intel
: 2D accelerated driver for X11 Window System.cifs-utils
: set of tools to mount SMB/CIFS shares.pulseaudio-alsa
: the well known sound server.pulseaudio-ctl
: control pulseaudio.slock
: a display locker for X11.xautolock
: an automatic X11 screen-locker/screen-saver.alsa-utils
: the ALSA (Advanced Linux Sound Architecture) utilities.redshift-minimal
: tool to adjust the color temperature of your screen.numlockx
: tool to turn on the numlock key in X11.usbutils
: USB device utilities.cmatrix
: Terminal based “The Matrix” like implementation.yubikey-touch-detector
: a tool to detect when your YubiKey is waiting for a touch.tlp
: advanced power management.powertop
: tool to enable various powersaving modes in userspace, kernel and hardware.
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:
bar
defines what you want to see in your action bar,spectrwm_fr.conf
sets the correct keyboard key mapping for a French keyboard. You can retrieve the one that fits to your keyboard in/etc/spectrwm/
. I’ve modified a lot of things in it to fit my keybinding requirements,spectrm.conf
sets other shortcuts to launch programs, display the action bar…
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:
Interface
value corresponds to your wireless interface name (useiwconfig
to find this information),Connection
value corresponds to the link type, if it’s wireless, it’swireless
, is it’s wired, it’sEthernet
,Security
value corresponds to the mecanism to use to connect to the network,ESSID
value corresponds to theSSID
of your access point,IP
value corresponds to the technique that needs to be used to retrieve an IP address. This value can also set tostatic
, if so, the keysAddress
,Gateway
andDNS
must be defined as explained here,Key
value corresponds to the PSK previously computed. Make sure to prefix it with\"
.
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):
- Toogle the bar on all workspaces:
MOD+b
. - Toggle the bar on the actual workspace:
MOD+Shift+b
. - Toggle focused window in floating mode:
MOD+t
. - Focus the next window (clockwise direction):
MOD+Tab
. - Focus the previous windows (counterclockwise):
MOD+Shift+Tab
. - Grow up the master window (the first program executed):
MOD+z
. - Shrink the master window:
MOD+a
. - Toggle focused window in fullscreen mode:
MOD+f
. - Move focused windows to workspace 1:
MOD+Shift+ampersand
. - Move focused windows to workspace 2:
MOD+Shift+eacute
. - Move focused windows to workspace 3:
MOD+Shift+quotedbl
. - Move focused windows to workspace 4:
MOD+Shift+apostrophe
. - Move focused windows to workspace 5:
MOD+Shift+parentleft
. - Move focused windows to workspace 6:
MOD+Shift+minus
. - Move focused windows to workspace 7:
MOD+Shift+egrave
. - Move focused windows to workspace 8:
MOD+Shift+underscore
. - Move focused windows to workspace 9:
MOD+Shift+ccedilla
. - Quit Spectrwm:
MOD+Shift+q
. - Restart Spectrwm:
MOD+Shift+r
. - Increase stack:
MOD+semicolon
. - Decrease stack:
MOD+comma
. - Swap focused window (clockwise direction):
MOD+Shift+j
. - Swap focused window (counterclockwise):
MOD+Shift+k
. - Close focused window:
MOD+c
. - Switch to workspace 1:
MOD+ampersand
. - Switch to workspace 2:
MOD+eacute
. - Switch to workspace 3:
MOD+quotedbl
. - Switch to workspace 4:
MOD+apostrophe
. - Switch to workspace 5:
MOD+parentleft
. - Switch to workspace 6:
MOD+minus
. - Switch to workspace 7:
MOD+egrave
. - Switch to workspace 8:
MOD+underscore
. - Switch to workspace 9:
MOD+ccedilla
.
Keep in mind to restart Spectrwm
(MOD+Shift+r
) after modifying its configuration.