* Repair theme symlinks the state-move migration left dangling 1781043107.sh re-linked legacy theme symlinks whose targets were stored with a literal "~/.config/omarchy/current/..." string. The replacement used the same literal tilde, which the filesystem never expands inside a symlink target, so btop, Helix, and VS Code/Cursor lost their theme and the migration reported success anyway. Fix the source migration to relink through the already-defined $current_state_dir variable, and add a follow-up migration that repairs the links the applied version left dangling — matching the existing 1785002349.sh pattern, so it is idempotent and leaves custom links alone. Co-Authored-By: Claude <noreply@anthropic.com> * Only repair theme symlinks that could never have worked The repair matched any target containing omarchy/current, so a working link into a user's own dotfiles was rewritten to the state directory and their setup was lost. Claim a link only when its target starts with a literal "~/", which the filesystem never expands, and names this exact theme file: that is what 1781043107.sh wrote, and no working link can look like it. A dangling target is not enough on its own, since a dotfiles repo may just be unmounted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Clean up every scratch directory the CLI suite creates Five of the eight mktemp directories were never registered with the exit trap, so each run left them behind in /tmp. Route them all through a helper that records them for cleanup. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Drop the theme symlink migration tests A migration runs once on each machine and is then inert, but a test for it sits in the suite forever. Now that the repair behaves correctly, keep the migration and let it go untested rather than grow the suite permanently. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: David Heinemeier Hansson <david@hey.com>
119 lines
3.3 KiB
Bash
119 lines
3.3 KiB
Bash
echo "Move current Omarchy theme state to ~/.local/state"
|
|
|
|
legacy_current_dir="$HOME/.config/omarchy/current"
|
|
current_state_dir="$HOME/.local/state/omarchy/current"
|
|
|
|
mkdir -p "$HOME/.local/state/omarchy"
|
|
|
|
if [[ -e $legacy_current_dir || -L $legacy_current_dir ]]; then
|
|
if [[ ! -e $current_state_dir && ! -L $current_state_dir ]]; then
|
|
mv "$legacy_current_dir" "$current_state_dir"
|
|
else
|
|
if [[ -d $legacy_current_dir && -d $current_state_dir ]]; then
|
|
cp -an "$legacy_current_dir/." "$current_state_dir/" 2>/dev/null || true
|
|
fi
|
|
rm -rf "$legacy_current_dir"
|
|
fi
|
|
fi
|
|
|
|
replace_literal_in_file() {
|
|
local file="$1"
|
|
local old="$2"
|
|
local new="$3"
|
|
local tmp
|
|
|
|
grep -Fq -- "$old" "$file" || return 0
|
|
|
|
tmp=$(mktemp)
|
|
OLD="$old" NEW="$new" awk '
|
|
BEGIN {
|
|
old = ENVIRON["OLD"]
|
|
new = ENVIRON["NEW"]
|
|
}
|
|
{
|
|
while ((pos = index($0, old)) > 0) {
|
|
$0 = substr($0, 1, pos - 1) new substr($0, pos + length(old))
|
|
}
|
|
print
|
|
}
|
|
' "$file" >"$tmp"
|
|
cat "$tmp" >"$file"
|
|
rm -f "$tmp"
|
|
}
|
|
|
|
replace_current_path() {
|
|
local file="$1"
|
|
|
|
[[ -f $file ]] || return 0
|
|
|
|
replace_literal_in_file "$file" "$HOME/.config/omarchy/current" "$HOME/.local/state/omarchy/current"
|
|
replace_literal_in_file "$file" "~/.config/omarchy/current" "~/.local/state/omarchy/current"
|
|
replace_literal_in_file "$file" "../omarchy/current" "../../.local/state/omarchy/current"
|
|
}
|
|
|
|
ensure_hyprland_state_path() {
|
|
local file="$HOME/.config/hypr/hyprland.lua"
|
|
local tmp
|
|
|
|
[[ -f $file ]] || return 0
|
|
grep -Fq '/.local/state/?.lua;' "$file" && return 0
|
|
grep -Fq '/default/hypr/bootstrap.lua' "$file" && return 0
|
|
grep -Fq ' .. "/.config/?.lua;"' "$file" || return 0
|
|
|
|
tmp=$(mktemp)
|
|
awk '
|
|
!inserted && $0 == " .. \"/.config/?.lua;\"" {
|
|
print " .. \"/.local/state/?.lua;\""
|
|
print " .. os.getenv(\"HOME\")"
|
|
inserted = 1
|
|
}
|
|
{ print }
|
|
' "$file" >"$tmp"
|
|
cat "$tmp" >"$file"
|
|
rm -f "$tmp"
|
|
}
|
|
|
|
for file in \
|
|
"$HOME/.config/alacritty/alacritty.toml" \
|
|
"$HOME/.config/foot/foot.ini" \
|
|
"$HOME/.config/ghostty/config" \
|
|
"$HOME/.config/hypr/hyprland.conf" \
|
|
"$HOME/.config/hypr/hyprland.lua" \
|
|
"$HOME/.config/hyprland-preview-share-picker/config.yaml" \
|
|
"$HOME/.config/kitty/kitty.conf"; do
|
|
replace_current_path "$file"
|
|
done
|
|
|
|
ensure_hyprland_state_path
|
|
|
|
relink_current_symlink() {
|
|
local link="$1"
|
|
local target suffix
|
|
|
|
[[ -L $link ]] || return 0
|
|
target=$(readlink "$link") || return 0
|
|
|
|
case "$target" in
|
|
"$legacy_current_dir"/*)
|
|
suffix=${target#"$legacy_current_dir"/}
|
|
ln -sfn "$current_state_dir/$suffix" "$link"
|
|
;;
|
|
"~/.config/omarchy/current/"*)
|
|
# The filesystem never expands a literal ~ in a symlink target, so keep
|
|
# $HOME out of the quoted string and let the shell expand it instead.
|
|
suffix=${target#"~/.config/omarchy/current/"}
|
|
ln -sfn "$current_state_dir/$suffix" "$link"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
for link in \
|
|
"$HOME/.config/btop/themes/current.theme" \
|
|
"$HOME/.config/helix/themes/omarchy.toml" \
|
|
"$HOME/.vscode/extensions/omarchy-theme/themes/omarchy-color-theme.json" \
|
|
"$HOME/.vscode-insiders/extensions/omarchy-theme/themes/omarchy-color-theme.json" \
|
|
"$HOME/.vscode-oss/extensions/omarchy-theme/themes/omarchy-color-theme.json" \
|
|
"$HOME/.cursor/extensions/omarchy-theme/themes/omarchy-color-theme.json"; do
|
|
relink_current_symlink "$link"
|
|
done
|