-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-i3.sh
More file actions
executable file
·71 lines (59 loc) · 1.79 KB
/
Copy pathsync-i3.sh
File metadata and controls
executable file
·71 lines (59 loc) · 1.79 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
#!/bin/bash
# Sync i3 + polybar + X11 tools
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh"
I3_DIRS=(i3 polybar picom)
collect() {
log_info "Collecting i3 configs from system to repo..."
for dir in "${I3_DIRS[@]}"; do
if [[ -d "$CONFIG_DIR/$dir" ]]; then
rm -rf "$DOTFILES_DIR/.config/$dir"
cp -r "$CONFIG_DIR/$dir" "$DOTFILES_DIR/.config/$dir"
log_ok "Collected: .config/$dir/"
else
log_warn "Not found: .config/$dir/"
fi
done
log_ok "i3 configs collected to repo"
}
install() {
log_info "Installing i3 configs from repo to system..."
check_packages i3 || log_warn "Some i3 packages missing (continuing anyway)"
for dir in "${I3_DIRS[@]}"; do
if [[ -d "$DOTFILES_DIR/.config/$dir" ]]; then
if [[ -d "$CONFIG_DIR/$dir" ]]; then
backup_dir "$CONFIG_DIR/$dir"
fi
rm -rf "$CONFIG_DIR/$dir"
cp -r "$DOTFILES_DIR/.config/$dir" "$CONFIG_DIR/$dir"
log_ok "Installed: .config/$dir/"
else
log_warn "Not in repo: .config/$dir/"
fi
done
log_ok "i3 configs installed to system"
}
validate() {
log_info "Validating i3 config..."
if [[ ! -f "$CONFIG_DIR/i3/config" ]]; then
log_error "i3 config not found"
return 1
fi
if i3 -C -c "$CONFIG_DIR/i3/config" 2>&1 | grep -qi "error"; then
log_error "i3 config has errors:"
i3 -C -c "$CONFIG_DIR/i3/config" 2>&1
return 1
fi
log_ok "i3 config is valid"
return 0
}
case "$1" in
--collect) collect ;;
--install) install ;;
--validate) validate ;;
*)
echo "Usage: $0 [--collect|--install|--validate]"
exit 1
;;
esac