Repository navigation
Expand file tree
/
Copy pathsetup-cleanup.sh
More file actions
executable file
·345 lines (295 loc) · 10.6 KB
/
Copy pathsetup-cleanup.sh
File metadata and controls
executable file
·345 lines (295 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
#!/bin/bash
# Cleanup stale Tailor-managed artifacts from previous versions.
# Idempotent: safe to re-run on every machine during migration.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh"
removed_any=false
remove_path() {
local path="$1"
if [ -e "$path" ] || [ -L "$path" ]; then
rm -rf "$path"
ok "Removed $path"
removed_any=true
fi
}
cleanup_figma_developer_mcp() {
hdr "figma-developer-mcp"
local figma_mcp_dir="$HOME/.local/share/figma-mcp"
local found=false
if [ -d "$figma_mcp_dir/node_modules/figma-developer-mcp" ] || \
{ [ -f "$figma_mcp_dir/package.json" ] && grep -q 'figma-developer-mcp' "$figma_mcp_dir/package.json"; }; then
found=true
remove_path "$figma_mcp_dir"
fi
if command -v npm >/dev/null 2>&1 && npm list -g figma-developer-mcp --depth=0 >/dev/null 2>&1; then
found=true
if npm uninstall -g figma-developer-mcp >/dev/null 2>&1; then
ok "Uninstalled global npm package figma-developer-mcp"
removed_any=true
else
warn "Could not uninstall global npm package figma-developer-mcp"
fi
fi
if [ "$found" = false ]; then
ok "figma-developer-mcp not installed"
fi
}
cleanup_legacy_herdr_layout_helpers() {
hdr "legacy Herdr layout helpers"
local found=false
local path rc
for path in \
"$HOME/.local/bin/herdr-dev" \
"$HOME/.local/bin/herdr-tds" \
"$HOME/.local/bin/herdr-tdlm" \
"$HOME/.local/bin/herdr-tsl"; do
if [ -f "$path" ] && grep -q 'HERDR_DEV_\|exec herdr-dev --layout\|herdr-tdlm' "$path" 2>/dev/null; then
found=true
remove_path "$path"
fi
done
for rc in "$HOME/.zshrc" "$HOME/.bashrc"; do
[ -f "$rc" ] || continue
if grep -q '# BEGIN TAILOR HERDR ALIASES' "$rc"; then
found=true
python3 - "$rc" <<'PY'
from pathlib import Path
import sys
path = Path(sys.argv[1])
begin = "# BEGIN TAILOR HERDR ALIASES\n"
end = "# END TAILOR HERDR ALIASES\n"
text = path.read_text()
start = text.find(begin)
if start != -1:
stop = text.find(end, start)
if stop != -1:
stop += len(end)
text = text[:start].rstrip() + "\n" + text[stop:].lstrip("\n")
path.write_text(text)
PY
ok "Removed legacy Herdr alias block from $rc"
removed_any=true
fi
done
if [ "$found" = false ]; then
ok "legacy Herdr layout helpers not installed"
fi
}
cleanup_legacy_hypr_bindings_conf() {
hdr "legacy Hyprland bindings.conf"
local path="$HOME/.config/hypr/bindings.conf"
if [ -f "$path" ] && \
grep -q 'Personal Hyprland bindings' "$path" 2>/dev/null && \
grep -q 'config/hypr/bindings.conf' "$path" 2>/dev/null; then
remove_path "$path"
else
ok "legacy Tailor bindings.conf not installed"
fi
}
# Older tailor managed Herdr: its own config.toml, a theme template + sync hook
# in ~/.config/omarchy, the herdr-omarchy plugin, and hdl/hds/hdlm/hsl
# symlinks. Omarchy now ships Herdr's config (themed via the terminal palette)
# and those layouts as shell functions, which the symlinks would shadow. Only
# files tailor recognizably wrote are touched.
cleanup_tailor_herdr() {
hdr "Tailor-managed Herdr"
local omarchy_path="${OMARCHY_PATH:-/usr/share/omarchy}"
local config=~/.config/herdr/config.toml
local backup="$config.bak.before-tailor-herdr"
local default_config="$omarchy_path/config/herdr/config.toml"
local found=false cmd link path
if [ -f "$config" ] && grep -q '^# Managed by Tailor' "$config" && [ -f "$default_config" ]; then
found=true
cp -f "$default_config" "$config"
ok "Restored Omarchy's Herdr config at $config"
removed_any=true
herdr server reload-config >/dev/null 2>&1 || true
fi
if [ -f "$backup" ] && cmp -s "$backup" "$default_config"; then
remove_path "$backup"
elif [ -f "$backup" ]; then
info "Kept $backup — it differs from Omarchy's default; merge anything you still want"
fi
# Unlinking goes through the herdr server. With no server running, drop the
# local link from the registry directly; nothing is holding it open.
local registry=~/.config/herdr/plugins.json linked='.plugin_id == "herdr-omarchy" and .source.kind == "local"'
if [ -f "$registry" ] && jq -e "any(.[]; $linked)" "$registry" >/dev/null 2>&1; then
found=true
if herdr plugin unlink herdr-omarchy >/dev/null 2>&1; then
ok "Unlinked herdr-omarchy plugin"
removed_any=true
elif jq "map(select(($linked) | not))" "$registry" > "$registry.tmp" && mv "$registry.tmp" "$registry"; then
ok "Removed herdr-omarchy from $registry (herdr server not running)"
removed_any=true
else
rm -f "$registry.tmp"
warn "Could not unlink herdr-omarchy plugin"
fi
fi
[ -d ~/.config/herdr/plugins/config/herdr-omarchy ] && { found=true; remove_path ~/.config/herdr/plugins/config/herdr-omarchy; }
for cmd in hdl hds hdlm hsl; do
link=~/.local/bin/$cmd
if [ -L "$link" ] && [[ "$(readlink "$link")" == */herdr-omarchy/bin/herdr-omarchy ]]; then
found=true
remove_path "$link"
fi
done
path=~/.config/omarchy/themed/herdr.toml.tpl
if [ -f "$path" ] && grep -q 'sync-herdr merges it into' "$path"; then
found=true
remove_path "$path"
fi
path=~/.config/omarchy/hooks/theme-set.d/sync-herdr
if [ -f "$path" ] && grep -q 'Sync the generated Omarchy Herdr theme fragment' "$path"; then
found=true
remove_path "$path"
fi
if [ "$found" = false ]; then
ok "no Tailor-managed Herdr setup found"
fi
}
# Older tailor copied input.conf and windows.conf into ~/.config/hypr. Omarchy's
# Lua config never loads them, and its defaults now cover their settings. Only
# removed on Lua-based setups (where nothing can source them) and only when the
# file is recognizably tailor's.
cleanup_legacy_hypr_conf_overrides() {
hdr "legacy Hyprland .conf overrides"
local input=~/.config/hypr/input.conf windows=~/.config/hypr/windows.conf
local found=false
if [ ! -f ~/.config/hypr/hyprland.lua ]; then
ok "not a Lua-based Hyprland config — leaving .conf files alone"
return 0
fi
if [ -f "$input" ] && grep -q '^# Personal Hyprland input overrides' "$input"; then
found=true
remove_path "$input"
fi
if [ -f "$windows" ] && grep -q 'name = windowrule-1' "$windows" && grep -q 'match:class = qemu' "$windows"; then
found=true
remove_path "$windows"
fi
if [ "$found" = false ]; then
ok "legacy Tailor input.conf/windows.conf not installed"
fi
}
# The old `swap` step wrote these; Omarchy now ships its own memory tuning.
# 99-swappiness.conf sorts after 99-omarchy-sysctl.conf, so it silently pins
# swappiness to 10 over Omarchy's zram-tuned value. The zram file is shadowed by
# Omarchy's drop-in but its migration keeps it as a "local edit". Only files
# still holding exactly what tailor wrote are removed.
cleanup_legacy_swap_tuning() {
hdr "legacy swap tuning"
local sysctl_file=/etc/sysctl.d/99-swappiness.conf
local zram_conf=/etc/systemd/zram-generator.conf
local zram_tailor=$'[zram0]\nzram-size = ram / 2\ncompression-algorithm = zstd'
local found=false
if [ -f "$sysctl_file" ] && [ "$(cat "$sysctl_file")" = "vm.swappiness=10" ]; then
found=true
if sudo rm -f "$sysctl_file" && sudo sysctl --system >/dev/null; then
ok "Removed $sysctl_file (swappiness now $(cat /proc/sys/vm/swappiness))"
removed_any=true
else
warn "Could not remove $sysctl_file"
return 1
fi
fi
if [ -f "$zram_conf" ] && [ "$(cat "$zram_conf")" = "$zram_tailor" ]; then
found=true
# No zram restart needed: Omarchy's drop-in already sizes the live device.
if sudo rm -f "$zram_conf"; then
ok "Removed $zram_conf"
removed_any=true
else
warn "Could not remove $zram_conf"
return 1
fi
fi
if [ "$found" = false ]; then
ok "legacy swap tuning not installed"
fi
}
# Older tailor installed Kitty and forced it as the Omarchy terminal. Put the
# default back to foot, then drop the package and Omarchy's copied kitty config
# (only if it's still the unmodified default).
cleanup_tailor_kitty() {
hdr "Tailor-installed Kitty"
local kitty_config=~/.config/kitty
local omarchy_kitty_conf="${OMARCHY_PATH:-$HOME/.local/share/omarchy}/config/kitty/kitty.conf"
local found=false
if [ "$(omarchy default terminal 2>/dev/null)" = "kitty" ]; then
found=true
if ! command -v foot >/dev/null 2>&1; then
warn "foot is not installed — leaving Kitty as the default terminal"
return 0
fi
if omarchy default terminal foot >/dev/null 2>&1; then
ok "Restored foot as the default terminal"
removed_any=true
else
warn "Could not restore foot as the default terminal"
return 1
fi
fi
if pacman -Q kitty >/dev/null 2>&1; then
found=true
if omarchy-pkg-drop kitty >/dev/null; then
ok "Removed kitty package"
removed_any=true
else
warn "Could not remove kitty package"
return 1
fi
fi
if [ -d "$kitty_config" ] && [ "$(ls -A "$kitty_config")" = "kitty.conf" ] && \
[ -f "$omarchy_kitty_conf" ] && cmp -s "$kitty_config/kitty.conf" "$omarchy_kitty_conf"; then
found=true
remove_path "$kitty_config"
elif [ -d "$kitty_config" ]; then
warn "Keeping $kitty_config (customized)"
fi
if [ "$found" = false ]; then
ok "Kitty not installed"
fi
}
# Older tailor deployed an OpenCode config (md-table plugin + MCPs) and two
# slash commands. Remove them only while they still carry tailor's content.
cleanup_tailor_opencode() {
hdr "Tailor OpenCode config"
local config_dir=~/.config/opencode
local found=false
if [ -f "$config_dir/opencode.jsonc" ] && \
grep -q 'opencode-md-table-formatter' "$config_dir/opencode.jsonc"; then
found=true
remove_path "$config_dir/opencode.jsonc"
fi
if [ -f "$config_dir/command/create-prd.md" ] && \
grep -q '^# Rule: Generating a Product Requirements Document (PRD)' "$config_dir/command/create-prd.md"; then
found=true
remove_path "$config_dir/command/create-prd.md"
fi
if [ -f "$config_dir/command/generate-tasks.md" ] && \
grep -q '^# Rule: Generating a Task List from User Requirements' "$config_dir/command/generate-tasks.md"; then
found=true
remove_path "$config_dir/command/generate-tasks.md"
fi
if [ "$found" = false ]; then
ok "Tailor OpenCode config not installed"
fi
}
echo "Cleaning up stale Tailor-managed artifacts..."
cleanup_figma_developer_mcp
cleanup_legacy_herdr_layout_helpers
cleanup_legacy_hypr_bindings_conf
cleanup_legacy_hypr_conf_overrides
cleanup_tailor_herdr
cleanup_legacy_swap_tuning
cleanup_tailor_opencode
cleanup_tailor_kitty
if [ "$removed_any" = true ]; then
echo ""
ok "Cleanup complete"
else
echo ""
ok "Nothing to clean up"
fi