foxygit / dotfiles Log in
commit 94a16d7532a896962a9a97ebef849432319fdc50
Author:     mrfox <jens.se@icloud.com>
AuthorDate: Wed Sep 23 18:50:59 2026 +0200
Commit:     mrfox <jens.se@icloud.com>
CommitDate: Wed Sep 23 18:50:59 2026 +0200

    add rebuild-sxwm.sh: standalone sxwm+patches rebuild/install

    Extracted install.sh's step_sxwm() into its own script: clone, apply
    the 7 local patches in order, build, sudo make install, verify the
    installed binary's md5 matches what was just built. No prompts, no
    other install.sh steps -- for when you only touched an sxwm patch and
    want to rebuild+install it directly.

    Verified: ran the clone+patch+build portion end to end just now: all 7
    patches (including focus-follows-mouse) apply cleanly against a fresh
    clone and the result is byte-identical (md5) to what's currently
    installed and running.

    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---
 README.md       |  4 +++-
 rebuild-sxwm.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 6965813..2c11bbf 100644
--- a/README.md
+++ b/README.md
@@ -134,6 +134,7 @@ desktop and forced a hard reboot.
 ```
 dotfiles/
 ├── install.sh                   # Main install script
+├── rebuild-sxwm.sh               # Standalone: rebuild+install just sxwm with its patches
 ├── BG/
 │   └── j9huwdxo1zzg1.jpeg       # Desktop wallpaper
 ├── bin/                          # Utility scripts, installed to ~/.local/bin
@@ -188,7 +189,8 @@ dotfiles/
 ## sxwm patches

 `install.sh` clones upstream `sxwm` and applies these on top before building, in
-order:
+order. To rebuild and reinstall just sxwm (e.g. after editing a patch) without
+running the rest of `install.sh`, use `./rebuild-sxwm.sh`.

 | Patch | Fixes |
 |---|---|
diff --git a/rebuild-sxwm.sh b/rebuild-sxwm.sh
new file mode 100755
index 0000000..46e8051
--- /dev/null
+++ b/rebuild-sxwm.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Minimal, standalone rebuild of sxwm with all local patches applied.
+#
+# Does exactly one thing: clone upstream sxwm, apply every *.patch in this
+# directory that install.sh's step_sxwm() applies (same order), build, and
+# `sudo make install`. No other install.sh steps (deps, sxbar, dmenu, st,
+# configs, ...) run. Useful when you only changed an sxwm patch and want to
+# rebuild+install it directly, without the interactive prompts.
+#
+# Usage: ./rebuild-sxwm.sh
+set -eu
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+SXWM_REPO="https://github.com/uint23/sxwm.git"
+BUILD_DIR="$(mktemp -d /tmp/sxwm-rebuild.XXXXXX)"
+
+PATCHES=(
+    cursor-dpi-fix.patch
+    net-active-window.patch
+    multi-monitor-struts.patch
+    monitor-hotplug-remap.patch
+    fullscreen-monitor-fix.patch
+    strut-fresh-screen-size.patch
+    focus-follows-mouse.patch
+)
+
+echo "==> Klonar sxwm i $BUILD_DIR..."
+git clone --depth=1 "$SXWM_REPO" "$BUILD_DIR"
+cd "$BUILD_DIR"
+
+echo "==> Applicerar patchar..."
+for p in "${PATCHES[@]}"; do
+    echo "    $p"
+    patch -p1 < "$SCRIPT_DIR/$p"
+done
+
+echo "==> Bygger..."
+make
+
+echo "==> Installerar (kräver sudo)..."
+sudo make install
+
+BIN_HASH=$(md5sum "$BUILD_DIR/sxwm" | cut -d' ' -f1)
+INSTALLED_HASH=$(md5sum /usr/local/bin/sxwm | cut -d' ' -f1)
+if [ "$BIN_HASH" = "$INSTALLED_HASH" ]; then
+    echo "==> Installerat och verifierat (samma md5: $BIN_HASH)."
+else
+    echo "==> VARNING: /usr/local/bin/sxwm matchar inte det nybyggda binaryt." >&2
+    echo "    byggt:      $BIN_HASH" >&2
+    echo "    installerat: $INSTALLED_HASH" >&2
+    exit 1
+fi
+
+echo ""
+echo "Filen på disk är uppdaterad, men sxwm läser inte om sig själv."
+echo "Starta om sxwm för att den nya binären ska börja gälla, t.ex.:"
+echo "  killall sxwm   (X-sessionen startar om sxwm om .xinitrc/en supervisor gör det)"
+echo "eller logga ut och in igen."
+
+rm -rf "$BUILD_DIR"