Setting Up a Workstation

For years I have been using Debian stable with the default Gnome desktop for my work computers, both my desktop workstation and laptop. Lately I have been missing the easy and simplicity of my old setup using tilling window managers and simple setup. For now I’ve decided to stay with Debian until I find a simple distribution that gets me what I need without too much fuzz.

Requirements

I need a reproducible build and I want to use dwm and a patched version of st. I want to have an up to date version of neovim and several tools set up and ready to use, most of this will require to have a newer version of Go or Rust install in the system so I will be installing the toolchain for both of them.

Setup

First I install the Debian base system without any graphics, I’ll manually set up the GUI after install. I create three partitions using LVM to set up encrypted partitions, I use the required /boot partition, one for the root filesystem and another that I mount in /mnt/storage. Instead of setting a partition for /home I link to directories in /mnt/storage from my /home, that way I can more easily use a different system with different defaults in my /home partition in the future and I can retain all my files that have nothing to do with the running of the system.

To avoid entering the password three times: once for each encrypted volume and another one for the login I configure slim to auto-login with my user and the second volume to unlock at the same time as the first. There are several ways to accomplish this but by far the easiest was just installing keyctl and keyctl and adding keyscript=decrypt_keyctl to /etc/crypttab.

primary-storage_crypt UUID=<UUID> none luks,discard,keyscript=decrypt_keyctl
primary-system_crypt  UUID=<UUID> none luks,discard,keyscript=decrypt_keyctl

GUI

For GUI I will be using X.org with dwm and st as my main work environment, with Firefox as my main real GUI tool. For most of my work I prefer TUI tools, I would even prefer to use [amfora][] to browse Gemini space but sadly most information resides in the Web with too much graphic overload.

apt install \
build-essential xinit x11-server-utils slim suckless-tools dunst cmus \
mupdf mupdf-tools ranger slock
mkdir src/; cd src/
apt source dwm
apt source stterm

# Modify the dwm configuration, build it and set it up to start.

The only changes that I do for dwm are setting the Windows key as the Mod key and setting up Mod+L to launch slock and block the screen. Everything else I left as they come in the defaults

st as the default terminal

I like how simple st is but I like to add the scrollback patch so it is a little more comfortable to use.

$ apt source stterm
$ cd stterm-0.9/
# Get and apply the scrollback patch
$ make clean
$ sudo make install
$ sudo update-alternatives --install /usr/bin/x-terminal-emulator \
st /usr/local/bin/st 10

Setting Neovim as the default editor

Neovim is another tool that I like to get the latest from the web instead of the Debian repositories as I sometimes waste some time by working with the plugins but that will be a whole other article. For now we just download it and set it up so it maps correctly.

wget https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod +x nvim.appimage
sudo mv nvim.appimage /usr/local/bin/nvim
sudo update-alternatives --install /usr/bin/vim vim /usr/local/bin/nvim 20

Don’t forget to set the EDITOR variable in ~/.bashrc so other programs know to call neovim when editing text.

--- snip ---
EDITOR=vim

export EDITOR
--- snip ---

Fix pipe and escape key in my laptop

There is an issue with my laptop in which the pipe/escape key is identified as a greater-than/lesser than key, so we need to run a command at start up to change its behavior as I use that key a lot when working on the shell. I like to use the rc.local service in systemd so I can just add commands into /etc/rc.local as it where a simpler rc system.

!#/bin/sh

setkeycodes 56 43
sudo chmod +x /etc/rc.local
sudo systemctl status rc-local.service
sudo systemctl start rc-local.service

Status bar

For my dwm status bar I got some code from cryptarch and modified for my own usage, as this script is run every second I like to keep it as simple as possible but I do like a couple of fancy features like the squares to show the percentage of battery and WiFi signal.


#!/bin/bash

setxkbmap us -variant dvorak-alt-intl -option caps:swapescape

feh --bg-scale $HOME/images/library.jpg

SEP="|"

# If we're in a cron job, we need to set up an environment,
# and if we're not in a cron job, the variable $- will contain the letter "i".
[[ $- == *i* ]] || {
    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$HOME/bin
}

convert_percent_to_bar() {
    nboxes=10
    filled=$(echo "($1+5)/$nboxes" | bc)
    unfilled=$(echo $nboxes-$filled | bc)
    echo -n $(yes ■ | head -$filled | tr '\n' ' ' | sed 's/ //g')
    echo -n $(yes □ | head -$unfilled | tr '\n' ' ' | sed 's/ //g')
}

get_battery_remaining_percent() {
    acpi | awk -F'%' '{print $1}' | awk '{print $NF}'
}

show_battery_status() {
    command -v acpi > /dev/null && {
        plugged=$(acpi | awk -F',' '{print $1}' | awk '{print $NF}')
        case $plugged in
            Charging)
                echo -n '[C]'
                ;;
            Discharging)
                echo -n '[D]'
                ;;
            ?) ;;
        esac
        convert_percent_to_bar $(get_battery_remaining_percent)
    }
}

show_wifi() {
    WIFI_CARD=$(ip link | grep -o "wlp[[:digit:]]\+s[[:digit:]]\+")
    SSID="$(iwconfig $WIFI_CARD | head -1 | awk -FSSID: '{print $2}' | sed 's/"//g')"
    LINK_QUALITY=$(iwconfig $WIFI_CARD | grep -o "Link Quality=[[:digit:]]\+/[[:digit:]]\+" | awk -F= '{print $2}')
    QUALITY_PERC=$(printf "%.03g\n" $(echo "100*$LINK_QUALITY" | bc -l))
    echo "$SSID $(convert_percent_to_bar ${QUALITY_PERC})"
}

show_date_time() {
    date +"%F %R"
}

while true; do
    statusline="$(show_battery_status)"
    statusline+="${SEP}$(show_wifi)"
    statusline+="${SEP}$(show_date_time)"
    xsetroot -name "$statusline"
    sleep 5s
done &

exec dwm

2024-12-30