Replaces the previous repo, which had split into two histories that never met (mainframe on a dead GitLab remote, the laptops on Gitea) with 146 dirty files across three machines and the NAS never enrolled at all. Branch-per-machine is gone. One main, with host differences expressed as small files under hosts/<hostname>/ rather than as branches, so there is nothing to merge. The reconciled zsh layer reduces 15-33 line forks to 1-7 effective lines per host; distro differences (oh-my-zsh prefix, syntax-highlighting path, fd vs fdfind) are probed in common/ instead. Fresh history: the old one carried six plaintext credentials, 45 MB of mail caches, browser caches and vendored binaries. 5,096 tracked files and 144 MB become 462 files and 2.6 MB. The .gitignore is now an allowlist, which is what keeps that true. Root cause of the rot: ~/.local/bin was a symlink to scripts/ with GOPATH inside it, so every go install wrote into version control (2.2 GB on the work laptop). PATH now points at the repo instead of the reverse. Also: Hyprland replaces sway and is sourced in two halves so $browser is defined before use; singleton automations carry ConditionHost= alongside host-layer-only placement; ddns moves from cron to a guarded timer; package manifests and pkg-snapshot/pkg-restore replace the X11-era install_scripts/; networkmanager-dmenu added to system76 (the binding always existed, the package never did).
66 lines
1.8 KiB
Bash
Executable File
66 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# Generate kanshi's dock profile from kernel EDID.
|
|
#
|
|
# Neither identity kanshi can see is trustworthy here: Hyprland reports each
|
|
# monitor's serial on the other monitor's output, and connector names get
|
|
# renumbered when the dock brings displays back in a different order. The
|
|
# kernel reads EDID over each connector's own DDC channel and is correct, so
|
|
# connector names are resolved from serials fresh on every display change.
|
|
|
|
USER_NAME=connorjohnstone
|
|
CONF=/home/$USER_NAME/.config/kanshi/generated
|
|
SCALE=1.5
|
|
|
|
# Serials in the physical left-to-right order they sit on the desk.
|
|
ORDER="PB4HB16301805 PB4HB16301801"
|
|
|
|
exec 9>/run/monitor-layout.lock
|
|
flock -w 60 9 || exit 0
|
|
|
|
[ -n "$LAYOUT_DELAY" ] && sleep "$LAYOUT_DELAY"
|
|
|
|
connector_for_serial() {
|
|
for c in /sys/class/drm/card*-*; do
|
|
[ -r "$c/status" ] || continue
|
|
[ "$(cat "$c/status")" = connected ] || continue
|
|
if edid-decode <"$c/edid" 2>/dev/null | grep -qF "'$1'"; then
|
|
echo "$c"
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
# Same directory as $CONF so the final rename is atomic: kanshi reloads on
|
|
# SIGHUP and must never observe a half-written config.
|
|
tmp=$(mktemp "$CONF.XXXXXX") || exit 1
|
|
trap 'rm -f "$tmp"' EXIT INT TERM
|
|
|
|
body=""
|
|
x=0
|
|
|
|
for serial in $ORDER; do
|
|
path=$(connector_for_serial "$serial") || continue
|
|
name=$(basename "$path" | sed 's/^card[0-9]*-//')
|
|
|
|
mode=$(head -1 "$path/modes" 2>/dev/null)
|
|
[ -n "$mode" ] || continue
|
|
width=$(awk -v m="${mode%%x*}" -v s="$SCALE" 'BEGIN{printf "%d", m / s}')
|
|
|
|
body="$body output $name enable position $x,0 scale $SCALE
|
|
"
|
|
x=$((x + width))
|
|
done
|
|
|
|
if [ -n "$body" ]; then
|
|
printf 'profile generated_dock {\n%s output eDP-1 disable\n}\n' "$body" >"$tmp"
|
|
else
|
|
: >"$tmp"
|
|
fi
|
|
|
|
chown "$USER_NAME:$USER_NAME" "$tmp"
|
|
chmod 0644 "$tmp"
|
|
mv -f "$tmp" "$CONF"
|
|
|
|
pkill -HUP -u "$USER_NAME" kanshi
|