#!/bin/sh # install.sh - deploy openbsd-dots to $HOME # downloads suckless sources, applies patches, copies configs, builds everything # run from the repo root as your normal user (doas used internally where needed) set -e DOTS="$(cd "$(dirname "$0")" && pwd)" SRC="$HOME/src" die() { echo "error: $1" >&2; exit 1; } confirm() { printf "%s [y/N] " "$1"; read ans; case "$ans" in y|Y) return 0 ;; *) return 1 ;; esac } backup() { [ -f "$1" ] && cp "$1" "$1.bak" && echo "backed up $1"; } # ftp is OpenBSD's built-in HTTP(S) fetcher fetch() { url="$1"; out="$2" echo " fetch $out..." ftp -o "$out" "$url" 2>&1 || die "failed to fetch $url" } echo "openbsd-dots installer" echo "1) download + build suckless sources" echo "2) install dotfiles (~/.profile, ~/.shrc, ~/.vimrc)" echo "" confirm "continue?" || exit 0 # --------------------------------------------------------------------------- # 1. sources # --------------------------------------------------------------------------- mkdir -p "$SRC" # tarballs to fetch: "name url" pairs TARBALLS=" libgrapheme-3.0.0 https://codemadness.org/releases/libgrapheme/libgrapheme-3.0.0.tar.gz dwm-6.8 https://dl.suckless.org/dwm/dwm-6.8.tar.gz st-0.9.3 https://dl.suckless.org/st/st-0.9.3.tar.gz dmenu-5.4 https://dl.suckless.org/tools/dmenu-5.4.tar.gz slock-1.6 https://dl.suckless.org/tools/slock-1.6.tar.gz surf-2.1 https://dl.suckless.org/surf/surf-2.1.tar.gz tabbed-0.9 https://dl.suckless.org/tools/tabbed-0.9.tar.gz ii-2.0 https://dl.suckless.org/tools/ii-2.0.tar.gz lchat-1.0 https://codemadness.org/releases/lchat/lchat-1.0.tar.gz " echo "" echo "==> downloading sources to $SRC..." echo "$TARBALLS" | while read name url; do [ -z "$name" ] && continue dir="$SRC/$name" tarball="$SRC/$name.tar.gz" if [ -d "$dir" ]; then echo " skip $name (already exists)" continue fi fetch "$url" "$tarball" tar -xzf "$tarball" -C "$SRC" rm "$tarball" echo " extracted $name" done # beastie: clone from forgejo if [ ! -d "$SRC/beastie" ]; then echo " cloning beastie..." git clone https://git.blockblitz.dev/beastie-fetch/beastie "$SRC/beastie" else echo " skip beastie (already exists)" fi # --------------------------------------------------------------------------- # 2. apply patches # --------------------------------------------------------------------------- echo "" echo "==> applying patches..." apply_patches() { tool="$1"; dir="$2"; patchdir="$DOTS/patches/$tool" [ -d "$patchdir" ] || return 0 for patch in "$patchdir"/*.diff; do [ -f "$patch" ] || continue name="$(basename "$patch")" echo " [$tool] $name" patch -d "$dir" -p1 < "$patch" || echo " WARNING: $name failed - may need manual review" done } apply_patches dwm "$SRC/dwm-6.8" apply_patches st "$SRC/st-0.9.3" apply_patches dmenu "$SRC/dmenu-5.4" apply_patches slock "$SRC/slock-1.6" apply_patches surf "$SRC/surf-2.1" # --------------------------------------------------------------------------- # 3. install ported config.h files # --------------------------------------------------------------------------- echo "" echo "==> installing config.h files..." install_config() { src="$DOTS/$1"; dst="$2/config.h" [ -f "$src" ] || { echo " skip $1 (not in dots)"; return; } cp "$src" "$dst" && echo " $1 -> $dst" } install_config dwm-config.h "$SRC/dwm-6.8" install_config st-config.h "$SRC/st-0.9.3" install_config dmenu-config.h "$SRC/dmenu-5.4" # --------------------------------------------------------------------------- # 4. build and install via install-all.sh # --------------------------------------------------------------------------- echo "" echo "==> running install-all.sh..." if [ -f "$SRC/install-all.sh" ]; then sh "$SRC/install-all.sh" else echo " $SRC/install-all.sh not found - skipping build" echo " clone your dotfiles/src repo or copy install-all.sh manually" fi # --------------------------------------------------------------------------- # 5. dotfiles # --------------------------------------------------------------------------- echo "" echo "==> installing dotfiles..." backup "$HOME/.profile"; cp "$DOTS/profile" "$HOME/.profile" && echo " .profile" backup "$HOME/.shrc"; cp "$DOTS/shrc" "$HOME/.shrc" && echo " .shrc" backup "$HOME/.vimrc"; cp "$DOTS/vimrc" "$HOME/.vimrc" && echo " .vimrc" echo "" echo "==> done." echo "" echo "notes:" echo " - super+v opens st instead of rexima (no equivalent on OpenBSD)" echo " - volume keys use sndioctl output.level=+/-0.05" echo " - X starts from /dev/ttyC0 (wscons)" echo " - install scientifica font: pkg_add scientifica" echo " - build warnings for surf are normal -- webkit deps may differ" echo " - slock needs suid: doas chmod u+s /usr/local/bin/slock"