-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·616 lines (575 loc) · 22.4 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
·616 lines (575 loc) · 22.4 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
#!/bin/bash
# Dotfiles update script
# Usage: ./update.sh [--collect|--install]
set -e
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOME_DIR="$HOME"
CONFIG_DIR="$HOME/.config"
OS="$(uname -s)" # Darwin or Linux — used for per-OS configs (e.g. ghostty)
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Home directory dotfiles
HOME_FILES=(
".bashrc"
".bash_profile"
".zshrc"
".p10k.zsh"
".profile"
".gitconfig"
".tmux.conf"
".nanorc"
".xinitrc"
".gtkrc-2.0"
".xprofile"
".fehbg"
# "CLAUDE.md" # Now symlinked: ~/CLAUDE.md → ~/rice/dotfiles-repo/CLAUDE.md
)
# .config directories to sync
CONFIG_DIRS=(
"i3"
"polybar"
"rofi"
"dunst"
"picom"
"kitty"
"btop"
"bat"
"atuin"
"cava"
"neofetch"
"lazygit"
"psd"
"gtk-3.0"
"flashfocus"
"mpv"
"wal"
"fontconfig"
"fastfetch"
"wm-common"
"sway"
"hypr"
"waybar"
"easyeffects"
"spicetify"
# Added 2026-01-10
"arch-update"
# NOTE: "ghostty" is handled per-OS below (config.macos / config.linux),
# not synced as a whole directory — see the ghostty blocks in collect/install.
"htop"
"spotifyd"
"flameshot"
"slimbookbattery"
"nnn"
"git"
"nvim"
"systemd/user"
)
# .config files to sync
CONFIG_FILES=(
"starship.toml"
"greenclip.toml"
)
# Claude Code settings - NOW SYMLINKED (no collect/install needed)
# ~/.claude/settings.json → ~/rice/dotfiles-repo/.claude/settings.json
# ~/.claude/settings.local.json → ~/rice/dotfiles-repo/.claude/settings.local.json
# CLAUDE_FILES=(
# "settings.json"
# "settings.local.json"
# )
# User scripts from .local/bin
LOCAL_BIN_SCRIPTS=(
"spotify-theme"
"power-switch"
# Added 2026-01-10
"battery-mode"
"clip2path"
"fix-keyring"
"update-mirrors"
"wttr"
# Dissertation workflow scripts (added 2026-01-10)
"diss-watch"
"diss-diff"
"diss-stats"
"diss-compress"
"diss-clean"
"diss-lint"
"diss-figures"
"diss-chapter"
# Hyprland helper scripts (added 2026-02-01)
"hypr-swap"
"hyprland-power-switch"
# Startpage scripts (added 2026-01-24)
"startpage-stats.sh"
"startpage-ping.sh"
# Claude Code helper scripts (added 2026-02-04)
"claude-backup"
"claude-undo"
"claude-stop-sync"
# Utility scripts (added 2026-02-20)
"captive-portal"
"vmware-macos"
"vmplayer-wayland"
)
# .local/share directories to sync
LOCAL_SHARE_DIRS=(
"icc" # ICC color profiles (Framework display calibration)
"startpage" # Custom browser startpage (added 2026-01-24)
)
# Boot configuration files (requires sudo)
BOOT_FILES=(
"refind_linux.conf"
)
# System configuration files (requires sudo)
SYSTEM_CONFIGS=(
"/etc/NetworkManager/dispatcher.d/90-captive-portal"
"/etc/modprobe.d/amd-pmc.conf"
"/etc/modprobe.d/amdgpu.conf"
"/etc/modprobe.d/blacklist-amdxdna.conf"
"/etc/systemd/sleep.conf.d/framework-amd.conf"
"/etc/systemd/logind.conf.d/lid-suspend-hibernate.conf"
"/etc/mkinitcpio.conf"
"/etc/udev/rules.d/60-ioschedulers.rules"
"/etc/udev/rules.d/85-power-switch.rules"
"/etc/scx_loader/config.toml"
# Added 2026-01-10
"/etc/systemd/system/keyring-update.service"
"/etc/systemd/system/keyring-update.timer"
"/etc/pacman.d/hooks/refresh-keyring.hook"
# Added 2026-01-16 (captive portal fix)
"/etc/NetworkManager/conf.d/20-connectivity.conf"
# Added 2026-02-01 (RAM optimizations)
"/etc/systemd/zram-generator.conf"
"/etc/sysctl.d/99-ram-optimizations.conf"
# Added 2026-02-01 (display tear-free + dmesg access)
"/etc/X11/xorg.conf.d/20-amdgpu.conf"
"/etc/sysctl.d/99-dmesg.conf"
# Added 2026-02-01 (logging system audit fixes)
"/etc/systemd/journald.conf.d/size.conf"
"/etc/logrotate.conf"
"/etc/logrotate.d/pacman"
# Added 2026-02-03 (logging audit round 2)
"/etc/logrotate.d/timeshift"
"/etc/logrotate.d/preload"
"/etc/systemd/system/logrotate.service.d/no-ac-requirement.conf"
"/etc/systemd/system/greetd.service.d/crash-limit.conf"
"/etc/sysctl.d/40-ipv6.conf"
# Added 2026-03-10 (WifiMan Teleport VPN setup)
"/etc/sysctl.conf"
# Added 2026-03-11 (S0i3 fix — Thunderbolt NHI wakeup blocker)
"/usr/lib/systemd/system-sleep/framework-s0i3-fix.sh"
)
collect_dotfiles() {
echo -e "${YELLOW}Collecting dotfiles from system...${NC}"
# Copy home directory dotfiles
for file in "${HOME_FILES[@]}"; do
if [[ -f "$HOME_DIR/$file" ]]; then
cp "$HOME_DIR/$file" "$DOTFILES_DIR/$file"
echo -e "${GREEN} Collected: $file${NC}"
else
echo -e "${RED} Not found: $file${NC}"
fi
done
# Copy .config directories
mkdir -p "$DOTFILES_DIR/.config"
for dir in "${CONFIG_DIRS[@]}"; do
if [[ -d "$CONFIG_DIR/$dir" ]]; then
rm -rf "$DOTFILES_DIR/.config/$dir"
cp -r "$CONFIG_DIR/$dir" "$DOTFILES_DIR/.config/"
echo -e "${GREEN} Collected: .config/$dir${NC}"
else
echo -e "${RED} Not found: .config/$dir${NC}"
fi
done
# Copy .config files
for file in "${CONFIG_FILES[@]}"; do
if [[ -f "$CONFIG_DIR/$file" ]]; then
cp "$CONFIG_DIR/$file" "$DOTFILES_DIR/.config/$file"
echo -e "${GREEN} Collected: .config/$file${NC}"
else
echo -e "${RED} Not found: .config/$file${NC}"
fi
done
# Ghostty: collect the live config into the per-OS file (macOS and Linux
# keep separate configs; the shared dir-sync above intentionally skips it).
if [[ -f "$CONFIG_DIR/ghostty/config" ]]; then
mkdir -p "$DOTFILES_DIR/.config/ghostty"
if [[ "$OS" == "Darwin" ]]; then
cp "$CONFIG_DIR/ghostty/config" "$DOTFILES_DIR/.config/ghostty/config.macos"
echo -e "${GREEN} Collected: .config/ghostty/config.macos${NC}"
else
cp "$CONFIG_DIR/ghostty/config" "$DOTFILES_DIR/.config/ghostty/config.linux"
echo -e "${GREEN} Collected: .config/ghostty/config.linux${NC}"
fi
else
echo -e "${RED} Not found: .config/ghostty/config${NC}"
fi
# Claude Code settings - SKIPPED (now symlinked to repo)
# for file in "${CLAUDE_FILES[@]}"; do
# if [[ -f "$HOME/.claude/$file" ]]; then
# cp "$HOME/.claude/$file" "$DOTFILES_DIR/.claude/$file"
# echo -e "${GREEN} Collected: .claude/$file${NC}"
# fi
# done
# Copy user scripts from .local/bin
mkdir -p "$DOTFILES_DIR/.local/bin"
for script in "${LOCAL_BIN_SCRIPTS[@]}"; do
if [[ -f "$HOME/.local/bin/$script" ]]; then
cp "$HOME/.local/bin/$script" "$DOTFILES_DIR/.local/bin/$script"
echo -e "${GREEN} Collected: .local/bin/$script${NC}"
else
echo -e "${RED} Not found: .local/bin/$script${NC}"
fi
done
# Copy .local/share directories
mkdir -p "$DOTFILES_DIR/.local/share"
for dir in "${LOCAL_SHARE_DIRS[@]}"; do
if [[ -d "$HOME/.local/share/$dir" ]]; then
rm -rf "$DOTFILES_DIR/.local/share/$dir"
cp -r "$HOME/.local/share/$dir" "$DOTFILES_DIR/.local/share/"
echo -e "${GREEN} Collected: .local/share/$dir${NC}"
else
echo -e "${RED} Not found: .local/share/$dir${NC}"
fi
done
# Copy rEFInd config (requires sudo)
if [[ -f "/boot/EFI/refind/refind.conf" ]]; then
mkdir -p "$DOTFILES_DIR/refind"
sudo cp /boot/EFI/refind/refind.conf "$DOTFILES_DIR/refind/"
sudo chown "$USER:$USER" "$DOTFILES_DIR/refind/refind.conf"
echo -e "${GREEN} Collected: refind/refind.conf${NC}"
fi
# Copy boot files (requires sudo)
for file in "${BOOT_FILES[@]}"; do
if [[ -f "/boot/$file" ]]; then
sudo cp "/boot/$file" "$DOTFILES_DIR/refind/$file"
sudo chown "$USER:$USER" "$DOTFILES_DIR/refind/$file"
echo -e "${GREEN} Collected: refind/$file${NC}"
else
echo -e "${RED} Not found: /boot/$file${NC}"
fi
done
# Copy system configs (requires sudo)
mkdir -p "$DOTFILES_DIR/system-configs/NetworkManager/conf.d"
mkdir -p "$DOTFILES_DIR/system-configs/modprobe.d"
mkdir -p "$DOTFILES_DIR/system-configs/systemd-sleep"
mkdir -p "$DOTFILES_DIR/system-configs/logind.conf.d"
mkdir -p "$DOTFILES_DIR/system-configs/udev.rules.d"
mkdir -p "$DOTFILES_DIR/system-configs/scx_loader"
mkdir -p "$DOTFILES_DIR/system-configs/sysctl.d"
mkdir -p "$DOTFILES_DIR/system-configs/xorg.conf.d"
mkdir -p "$DOTFILES_DIR/system-configs/journald.conf.d"
mkdir -p "$DOTFILES_DIR/system-configs/logrotate.d"
mkdir -p "$DOTFILES_DIR/system-configs/system-sleep"
for filepath in "${SYSTEM_CONFIGS[@]}"; do
if [[ -f "$filepath" ]]; then
filename=$(basename "$filepath")
case "$filepath" in
*/NetworkManager/conf.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/NetworkManager/conf.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/NetworkManager/conf.d/$filename"
;;
*/NetworkManager/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/NetworkManager/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/NetworkManager/$filename"
;;
*/modprobe.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/modprobe.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/modprobe.d/$filename"
;;
*/sleep.conf.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/systemd-sleep/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/systemd-sleep/$filename"
;;
*/logind.conf.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/logind.conf.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/logind.conf.d/$filename"
;;
*/mkinitcpio.conf|*/sysctl.conf)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/$filename"
;;
*/udev/rules.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/udev.rules.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/udev.rules.d/$filename"
;;
*/scx_loader/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/scx_loader/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/scx_loader/$filename"
;;
*/systemd/system/*)
relpath="${filepath#/etc/systemd/system/}"
mkdir -p "$DOTFILES_DIR/system-configs/systemd-system/$(dirname "$relpath")"
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/systemd-system/$relpath"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/systemd-system/$relpath"
;;
*/pacman.d/hooks/*)
mkdir -p "$DOTFILES_DIR/system-configs/pacman.d/hooks"
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/pacman.d/hooks/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/pacman.d/hooks/$filename"
;;
*/sysctl.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/sysctl.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/sysctl.d/$filename"
;;
*/xorg.conf.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/xorg.conf.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/xorg.conf.d/$filename"
;;
*/journald.conf.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/journald.conf.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/journald.conf.d/$filename"
;;
*/logrotate.d/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/logrotate.d/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/logrotate.d/$filename"
;;
*/logrotate.conf)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/$filename"
;;
*/system-sleep/*)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/system-sleep/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/system-sleep/$filename"
;;
*/zram-generator.conf)
sudo cp "$filepath" "$DOTFILES_DIR/system-configs/$filename"
sudo chown "$USER:$USER" "$DOTFILES_DIR/system-configs/$filename"
;;
esac
echo -e "${GREEN} Collected: system-configs/.../$filename${NC}"
else
echo -e "${RED} Not found: $filepath${NC}"
fi
done
echo -e "${GREEN}Done! Review changes with 'git diff'${NC}"
}
install_dotfiles() {
echo -e "${YELLOW}Installing dotfiles to system...${NC}"
# Create backup directory
BACKUP_DIR="$HOME/.dotfiles-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"
echo -e "${YELLOW}Backup directory: $BACKUP_DIR${NC}"
# Install home directory dotfiles
for file in "${HOME_FILES[@]}"; do
if [[ -f "$DOTFILES_DIR/$file" ]]; then
# Backup existing
if [[ -f "$HOME_DIR/$file" ]]; then
cp "$HOME_DIR/$file" "$BACKUP_DIR/"
fi
cp "$DOTFILES_DIR/$file" "$HOME_DIR/$file"
echo -e "${GREEN} Installed: $file${NC}"
fi
done
# Install .config directories
mkdir -p "$CONFIG_DIR"
for dir in "${CONFIG_DIRS[@]}"; do
if [[ -d "$DOTFILES_DIR/.config/$dir" ]]; then
# Backup existing
if [[ -d "$CONFIG_DIR/$dir" ]]; then
cp -r "$CONFIG_DIR/$dir" "$BACKUP_DIR/"
fi
rm -rf "$CONFIG_DIR/$dir"
cp -r "$DOTFILES_DIR/.config/$dir" "$CONFIG_DIR/"
echo -e "${GREEN} Installed: .config/$dir${NC}"
fi
done
# Install .config files
for file in "${CONFIG_FILES[@]}"; do
if [[ -f "$DOTFILES_DIR/.config/$file" ]]; then
# Backup existing
if [[ -f "$CONFIG_DIR/$file" ]]; then
cp "$CONFIG_DIR/$file" "$BACKUP_DIR/"
fi
cp "$DOTFILES_DIR/.config/$file" "$CONFIG_DIR/$file"
echo -e "${GREEN} Installed: .config/$file${NC}"
fi
done
# Ghostty: install the per-OS config as ~/.config/ghostty/config
if [[ "$OS" == "Darwin" ]]; then
GHOSTTY_SRC="$DOTFILES_DIR/.config/ghostty/config.macos"
else
GHOSTTY_SRC="$DOTFILES_DIR/.config/ghostty/config.linux"
fi
if [[ -f "$GHOSTTY_SRC" ]]; then
mkdir -p "$CONFIG_DIR/ghostty"
if [[ -f "$CONFIG_DIR/ghostty/config" ]]; then
cp "$CONFIG_DIR/ghostty/config" "$BACKUP_DIR/ghostty-config.bak"
fi
cp "$GHOSTTY_SRC" "$CONFIG_DIR/ghostty/config"
echo -e "${GREEN} Installed: .config/ghostty/config (from $(basename "$GHOSTTY_SRC"))${NC}"
fi
# Install user scripts from .local/bin
mkdir -p "$HOME/.local/bin"
for script in "${LOCAL_BIN_SCRIPTS[@]}"; do
if [[ -f "$DOTFILES_DIR/.local/bin/$script" ]]; then
cp "$DOTFILES_DIR/.local/bin/$script" "$HOME/.local/bin/$script"
chmod +x "$HOME/.local/bin/$script"
echo -e "${GREEN} Installed: .local/bin/$script${NC}"
fi
done
# Install .local/share directories
mkdir -p "$HOME/.local/share"
for dir in "${LOCAL_SHARE_DIRS[@]}"; do
if [[ -d "$DOTFILES_DIR/.local/share/$dir" ]]; then
# Backup existing
if [[ -d "$HOME/.local/share/$dir" ]]; then
cp -r "$HOME/.local/share/$dir" "$BACKUP_DIR/"
fi
rm -rf "$HOME/.local/share/$dir"
cp -r "$DOTFILES_DIR/.local/share/$dir" "$HOME/.local/share/"
echo -e "${GREEN} Installed: .local/share/$dir${NC}"
fi
done
# Claude Code settings - SKIPPED (now symlinked to repo)
# Symlinks: ~/.claude/settings.json → ~/rice/dotfiles-repo/.claude/settings.json
# To set up symlinks on a fresh machine, run:
# ln -s ~/rice/dotfiles-repo/.claude/settings.json ~/.claude/settings.json
# ln -s ~/rice/dotfiles-repo/.claude/settings.local.json ~/.claude/settings.local.json
echo -e "${GREEN}Done! Backups saved to: $BACKUP_DIR${NC}"
echo -e "${YELLOW}You may need to restart your shell or WM to see changes.${NC}"
}
install_system() {
echo -e "${YELLOW}Installing system configs (requires sudo)...${NC}"
# Install boot files
for file in "${BOOT_FILES[@]}"; do
if [[ -f "$DOTFILES_DIR/refind/$file" ]]; then
sudo cp "/boot/$file" "/boot/$file.bak" 2>/dev/null
sudo cp "$DOTFILES_DIR/refind/$file" "/boot/$file"
echo -e "${GREEN} Installed: /boot/$file${NC}"
fi
done
# Install system configs
for filepath in "${SYSTEM_CONFIGS[@]}"; do
filename=$(basename "$filepath")
case "$filepath" in
*/NetworkManager/conf.d/*)
src="$DOTFILES_DIR/system-configs/NetworkManager/conf.d/$filename"
;;
*/NetworkManager/*)
src="$DOTFILES_DIR/system-configs/NetworkManager/$filename"
;;
*/modprobe.d/*)
src="$DOTFILES_DIR/system-configs/modprobe.d/$filename"
;;
*/sleep.conf.d/*)
src="$DOTFILES_DIR/system-configs/systemd-sleep/$filename"
;;
*/logind.conf.d/*)
src="$DOTFILES_DIR/system-configs/logind.conf.d/$filename"
;;
*/mkinitcpio.conf)
src="$DOTFILES_DIR/system-configs/$filename"
;;
*/udev/rules.d/*)
src="$DOTFILES_DIR/system-configs/udev.rules.d/$filename"
;;
*/scx_loader/*)
src="$DOTFILES_DIR/system-configs/scx_loader/$filename"
;;
*/systemd/system/*)
relpath="${filepath#/etc/systemd/system/}"
src="$DOTFILES_DIR/system-configs/systemd-system/$relpath"
;;
*/pacman.d/hooks/*)
src="$DOTFILES_DIR/system-configs/pacman.d/hooks/$filename"
;;
*/sysctl.d/*)
src="$DOTFILES_DIR/system-configs/sysctl.d/$filename"
;;
*/xorg.conf.d/*)
src="$DOTFILES_DIR/system-configs/xorg.conf.d/$filename"
;;
*/journald.conf.d/*)
src="$DOTFILES_DIR/system-configs/journald.conf.d/$filename"
;;
*/logrotate.d/*)
src="$DOTFILES_DIR/system-configs/logrotate.d/$filename"
;;
*/logrotate.conf)
src="$DOTFILES_DIR/system-configs/$filename"
;;
*/system-sleep/*)
src="$DOTFILES_DIR/system-configs/system-sleep/$filename"
;;
*/zram-generator.conf)
src="$DOTFILES_DIR/system-configs/$filename"
;;
esac
if [[ -f "$src" ]]; then
sudo cp "$filepath" "$filepath.bak" 2>/dev/null
sudo mkdir -p "$(dirname "$filepath")"
sudo cp "$src" "$filepath"
sudo chmod +x "$filepath" 2>/dev/null # For scripts
echo -e "${GREEN} Installed: $filepath${NC}"
fi
done
echo -e "${GREEN}Done! Some changes may require reboot.${NC}"
}
install_refind() {
echo -e "${YELLOW}Installing rEFInd config (requires sudo)...${NC}"
if [[ -f "$DOTFILES_DIR/refind/refind.conf" ]]; then
sudo cp /boot/EFI/refind/refind.conf /boot/EFI/refind/refind.conf.bak
sudo cp "$DOTFILES_DIR/refind/refind.conf" /boot/EFI/refind/
echo -e "${GREEN} Installed: refind.conf (backup: refind.conf.bak)${NC}"
else
echo -e "${RED} Not found: refind/refind.conf${NC}"
fi
}
show_help() {
echo "Dotfiles update script"
echo ""
echo "Usage: $0 [option]"
echo ""
echo "Options:"
echo " --collect Collect dotfiles from system into repo"
echo " --install Install dotfiles from repo to system (user configs)"
echo " --system Install system configs (boot, modprobe, etc. - requires sudo)"
echo " --refind Install rEFInd config only (requires sudo)"
echo " --help Show this help message"
echo ""
echo "Examples:"
echo " $0 --collect # After making changes, sync to repo"
echo " $0 --install # Fresh install or restore from repo"
echo " $0 --system # Install system-level configs (Framework 13 AMD)"
echo ""
echo "Collected files include:"
echo " - Home dotfiles (.zshrc, .gitconfig, etc.)"
echo " - .config directories (i3, sway, hypr, polybar, waybar, kitty, etc.)"
echo " - Shared WM configs (wm-common/)"
echo " - Boot configs (refind_linux.conf, refind.conf)"
echo " - System configs (modprobe, sleep, udev rules, scx_loader)"
echo ""
echo "Symlinked files (auto-synced, no collect needed):"
echo " - ~/CLAUDE.md → dotfiles-repo/CLAUDE.md"
echo " - ~/.claude/settings.json → dotfiles-repo/.claude/settings.json"
echo ""
echo "Per-OS configs (auto-selected by uname):"
echo " - ghostty: .config/ghostty/config.macos (macOS) / config.linux (Linux)"
echo ""
echo "For WM-specific sync, use: ./sync-wm.sh --help"
}
case "$1" in
--collect)
collect_dotfiles
;;
--install)
install_dotfiles
;;
--system)
install_system
;;
--refind)
install_refind
;;
--help|-h|"")
show_help
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
show_help
exit 1
;;
esac