Repository navigation
Expand file tree
/
Copy pathsave.sh
More file actions
executable file
·228 lines (197 loc) · 7.52 KB
/
Copy pathsave.sh
File metadata and controls
executable file
·228 lines (197 loc) · 7.52 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
#!/bin/bash
# save.sh — Copy configs into ~/.dotfiles/ and commit+push
set -e
DOTFILES="$HOME/.dotfiles"
# Safe copy: skip if source and dest are the same file (symlink scenario)
safe_cp() {
local src="$1" dst="$2"
# If dst is a directory, append src's basename
if [ -d "$dst" ]; then
dst="$dst/$(basename "$src")"
fi
# Skip if same file (source is a symlink to dest inside DOTFILES)
if [ -f "$src" ] && [ -f "$dst" ] && [ "$src" -ef "$dst" ]; then
return 0
fi
cp -a "$src" "$dst"
}
# Copy all regular files from src_dir into dst_dir (skip dirs, .bak)
safe_cp_dir() {
local src_dir="$1" dst_dir="$2" pattern="${3:-*}"
mkdir -p "$dst_dir"
for entry in "$src_dir"/$pattern; do
[ -e "$entry" ] || continue
b="$(basename "$entry")"
[[ "$b" == *.bak.* ]] || [[ "$b" == *.bak[0-9]* ]] || [[ "$b" == *.bak_* ]] && continue
# Only regular files — skip dirs (they're symlinks into the repo)
[ -f "$entry" ] || continue
safe_cp "$entry" "$dst_dir/"
done
}
echo "=== Copying configs to $DOTFILES ==="
# Hyprland
echo "[hypr]"
mkdir -p "$DOTFILES/.config/hypr"
safe_cp_dir "$HOME/.config/hypr" "$DOTFILES/.config/hypr" "*.conf"
safe_cp_dir "$HOME/.config/hypr" "$DOTFILES/.config/hypr" "*.lua"
# PipeWire AirPlay
echo "[pipewire]"
mkdir -p "$DOTFILES/.config/pipewire/pipewire.conf.d"
safe_cp "$HOME/.config/pipewire/pipewire.conf.d/raop-discover.conf" "$DOTFILES/.config/pipewire/pipewire.conf.d/raop-discover.conf"
safe_cp "$HOME/.config/pipewire/pipewire.conf.d/oficina-stereo.conf" "$DOTFILES/.config/pipewire/pipewire.conf.d/oficina-stereo.conf"
# Btop
echo "[btop]"
mkdir -p "$DOTFILES/.config/btop"
safe_cp "$HOME/.config/btop/btop.conf" "$DOTFILES/.config/btop/btop.conf"
# Fastfetch
echo "[fastfetch]"
safe_cp_dir "$HOME/.config/fastfetch" "$DOTFILES/.config/fastfetch"
# Terminal
echo "[terminal]"
safe_cp "$HOME/.config/alacritty/alacritty.toml" "$DOTFILES/.config/alacritty/alacritty.toml"
safe_cp "$HOME/.config/foot/foot.ini" "$DOTFILES/.config/foot/foot.ini"
mkdir -p "$DOTFILES/.local/share/icons"
safe_cp "$HOME/.local/share/icons/foot.svg" "$DOTFILES/.local/share/icons/foot.svg"
# Fresh terminal IDE
echo "[fresh]"
safe_cp "$HOME/.config/fresh/config.json" "$DOTFILES/.config/fresh/config.json"
# Systemd user services
echo "[systemd]"
mkdir -p "$DOTFILES/.config/systemd/user"
for f in "$HOME/.config/systemd/user/"*.service "$HOME/.config/systemd/user/"*.timer; do
[ -f "$f" ] || continue
# Skip symlinks to /dev/null (Nextcloud noise)
[ -L "$f" ] && [ "$(readlink "$f")" = "/dev/null" ] && continue
safe_cp "$f" "$DOTFILES/.config/systemd/user/"
done
# Service drop-in overrides (copy as-is, they're small config dirs)
for d in "$HOME/.config/systemd/user/"*.service.d; do
[ -d "$d" ] || continue
# Skip if already symlinked into our repo
b="$(basename "$d")"
dst="$DOTFILES/.config/systemd/user/$b"
if [ -d "$dst" ] && [ "$d" -ef "$dst" ]; then
continue # same dir via symlink
fi
cp -a "$d" "$dst"
done
# Autostart
echo "[autostart]"
mkdir -p "$DOTFILES/.config/autostart"
safe_cp_dir "$HOME/.config/autostart" "$DOTFILES/.config/autostart" "*.desktop"
# Environment
echo "[environment]"
safe_cp_dir "$HOME/.config/environment.d" "$DOTFILES/.config/environment.d"
# Chromium flags
safe_cp "$HOME/.config/chromium-flags.conf" "$DOTFILES/.config/chromium-flags.conf"
# Omarchy shell config
safe_cp "$HOME/.config/omarchy/shell.json" "$DOTFILES/.config/omarchy/shell.json"
# Hyprshell (window switcher, SUPER+TAB)
echo "[hyprshell]"
mkdir -p "$DOTFILES/.config/hyprshell"
safe_cp "$HOME/.config/hyprshell/config.ron" "$DOTFILES/.config/hyprshell/config.ron"
safe_cp "$HOME/.config/hyprshell/styles.css" "$DOTFILES/.config/hyprshell/styles.css"
# Omarchy hooks (only regular files, skip dir symlinks)
echo "[omarchy hooks]"
mkdir -p "$DOTFILES/.config/omarchy/hooks"
for entry in "$HOME/.config/omarchy/hooks/"*; do
[ -f "$entry" ] || continue # skip dirs (they're symlinks into repo)
b="$(basename "$entry")"
[[ "$b" == *.sample ]] && continue # sample files not needed
safe_cp "$entry" "$DOTFILES/.config/omarchy/hooks/"
done
# Omarchy extensions
echo "[omarchy extensions]"
safe_cp_dir "$HOME/.config/omarchy/extensions" "$DOTFILES/.config/omarchy/extensions"
# Omarchy branding
echo "[omarchy branding]"
safe_cp_dir "$HOME/.config/omarchy/branding" "$DOTFILES/.config/omarchy/branding"
# Custom scripts
echo "[scripts]"
mkdir -p "$DOTFILES/.local/bin"
for s in teams-jiggler teams-jiggler-status teams-jiggler-toggle teams-jiggler-off \
nextcloud-external-guard nextcloud-dock-off nextcloud-dock-on \
omarchy-webapp-patch omarchy-calendar-sync-caldav update-fingerprint-libs \
save-dotfiles restore-dotfiles askpass lid-is-open \
music-to-storagebox check-storagebox-music-mount lock-storagebox-music-dir \
espanso_recovery_watch.py; do
[ -f "$HOME/.local/bin/$s" ] || continue
safe_cp "$HOME/.local/bin/$s" "$DOTFILES/.local/bin/"
done
# Omarchy → Zen Browser theme sync
# Keep renderer/template reproducible; the live files may be symlinks into repo.
echo "[omarchy-zen-sync]"
safe_cp_dir "$HOME/.local/share/omarchy-zen-sync" "$DOTFILES/.local/share/omarchy-zen-sync"
# Root-owned PAM policy and lid-state helper (plain copies; restore needs sudo)
echo "[system files]"
mkdir -p "$DOTFILES/etc/pam.d"
for f in sudo polkit-1; do
[ -f "/etc/pam.d/$f" ] && safe_cp "/etc/pam.d/$f" "$DOTFILES/etc/pam.d/$f"
done
[ -f /usr/local/bin/lid-is-open ] && safe_cp /usr/local/bin/lid-is-open "$DOTFILES/.local/bin/lid-is-open"
# Pith config (whole-dir symlinks; db/ is live SQLite state — never tracked)
echo "[pith]"
mkdir -p "$HOME/.pith"
for d in skills memory; do
src="$HOME/.pith/$d"
dst="$DOTFILES/.pith/$d"
if [ -L "$src" ] && [ "$src" -ef "$dst" ]; then
: # already symlinked into repo
elif [ -d "$src" ]; then
mkdir -p "$DOTFILES/.pith"
rm -rf "$dst"
cp -a "$src" "$dst"
rm -rf "$src"
ln -s "$dst" "$src"
echo " TRACK+LINK .pith/$d -> $src"
fi
done
# Pi agent skills (ensure symlinks)
echo "[pi agent skills]"
mkdir -p "$HOME/.pi/agent/skills"
if [ ! -L "$HOME/.pi/agent/skills/sudo-askpass" ]; then
echo " SYMLINK .pi/agent/skills/sudo-askpass"
[ -e "$HOME/.pi/agent/skills/sudo-askpass" ] && rm -rf "$HOME/.pi/agent/skills/sudo-askpass"
ln -sf "$DOTFILES/.agents/skills/sudo-askpass" "$HOME/.pi/agent/skills/sudo-askpass"
fi
# Web app desktop files and icons (created by omarchy-webapp-install)
echo "[webapps]"
mkdir -p "$DOTFILES/.local/share/applications/icons"
for f in Outlook.desktop Teams.desktop OneDrive.desktop Hache.desktop Tailscale.desktop \
icons/Outlook.png icons/Teams.png icons/OneDrive.png icons/Hache.png icons/Tailscale.png; do
src="$HOME/.local/share/applications/$f"
[ -e "$src" ] || continue
safe_cp "$src" "$DOTFILES/.local/share/applications/$f"
done
# TTT terminal editor launcher
echo "[ttt]"
if [ -f "$HOME/.local/share/applications/ttt.desktop" ]; then
safe_cp "$HOME/.local/share/applications/ttt.desktop" "$DOTFILES/.local/share/applications/ttt.desktop"
fi
echo ""
echo "=== Git add + commit ==="
cd "$DOTFILES"
git config core.hooksPath .githooks
# Update .gitignore
cat > .gitignore << 'GITIGNORE'
themes/
.zshrc_old
.zshenv.local
*.bak.*
.bak/
GITIGNORE
git add -A
if git diff --cached --quiet; then
echo "Nothing changed — skipping commit."
else
git commit -m "dotfiles: save $(date +%Y-%m-%d_%H%M)"
echo ""
echo "=== Push to origin ==="
if git remote get-url origin &>/dev/null; then
git push
else
echo "No remote configured. Commit saved locally."
fi
fi
echo ""
echo "Done."