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
Clone my dotfiles
My configuration files (dotfiles) are available for free. Clone them in your home directory.
git clone https://gitea.illuad.fr/adrien/dotfiles.git
Install required 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-*: 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,
netctl: a CLI and profile-based network manager,
dhcpcd: a DHCP and DHCPv6 client.
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
xinit program allows a user to manually start an Xorg display server. The
startx script is a front-end for
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/numlockx /usr/bin/xautolock -time 3 -locker slock & ~/.fehbg exec spectrwm
xautolock binary will lock your system if no activity is detected during three minutes, by executing
slock. Later, we will see the
.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 graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then exec startx fi
The configuration directory of
Spectrwm is located at
mkdir -p ~/.config/spectrwm cp ~/dotfiles/.config/spectrwm/* ~/.config/spectrwm/
bardefines what you want to see in your action bar,
spectrwm_fr.confsets 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.confsets 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
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
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
Section "ServerFlags" Option "DontVTSwitch" "True" Option "DontZap" "True" EndSection"
Screen lock configuration
Below, the configuration for
slock. Copy the following snippet into
[Unit] Description=Lock X11 session using slock for user %i Before=sleep.target [Service] User=%i Environment=DISPLAY=:0 ExecStartPre=/usr/bin/xset dpms force suspend ExecStart=/usr/bin/slock [Install] WantedBy=sleep.target
slock service. Replace
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" EndSection
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 (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 (
mkdir ~/.config/rofi cp ~/dotfiles/.config/rofi/config ~/.config/rofi/config
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.
As always, modify the following file according to your preferences.
cp ~/dotfiles/.config/fish/config.fish .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
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
[Unit] Description=Freebox share Wants=network-online.target After=network-online.target [Mount] Environment="SERVER='//<router_IP_address>/<share_name>'" What=$SERVER Where=/mnt/data Type=cifs Options=credentials=/etc/samba/credentials/data,_netdev,cache=none,users,user,noacl,guest,rw,,uid=1000,gid=985,iocharset=utf8,vers=1.0 SloppyOptions=On DirectoryMode=0755 TimeoutSec=10 [Install] WantedBy=multi-user.target
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.
[Unit] Description=Auto mount Freebox share [Automount] Where=/mnt/data [Install] WantedBy=multi-user.target
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 <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:
Interfacevalue corresponds to your wireless interface name (use
iwconfigto find this information),
Connectionvalue corresponds to the link type, if it’s wireless, it’s
wireless, is it’s wired, it’s
Securityvalue corresponds to the mecanism to use to connect to the network,
ESSIDvalue corresponds to the
SSIDof your access point,
IPvalue corresponds to the technique that needs to be used to retrieve an IP address. This value can also set to
static, if so, the keys
DNSmust be defined as explained here,
Keyvalue corresponds to the PSK previously computed. Make sure to prefix it with
To start this profile, you must execute the following command.
sudo netctl start wlanHome
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
- toogle the bar on all workspaces:
- toggle the bar on the actual workspace:
- toggle focused window in floating mode:
- focus the next window (clockwise direction):
- focus the previous windows (counterclockwise):
- grow up the master window (the first program executed):
- shrink the master window:
- toggle focused window in fullscreen mode:
- move focused windows to workspace 1:
- move focused windows to workspace 2:
- move focused windows to workspace 3:
- move focused windows to workspace 4:
- move focused windows to workspace 5:
- move focused windows to workspace 6:
- move focused windows to workspace 7:
- move focused windows to workspace 8:
- move focused windows to workspace 9:
- quit Spectrwm:
- restart Spectrwm:
- increase stack:
- decrease stack:
- swap focused window (clockwise direction):
- swap focused window (counterclockwise):
- close focused window:
- switch to workspace 1:
- switch to workspace 2:
- switch to workspace 3:
- switch to workspace 4:
- switch to workspace 5:
- switch to workspace 6:
- switch to workspace 7:
- switch to workspace 8:
- switch to workspace 9:
Keep in mind to restart
MOD+Shift+r) after modifying its configuration.