-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-sway.sh
More file actions
executable file
·78 lines (65 loc) · 2.09 KB
/
Copy pathsync-sway.sh
File metadata and controls
executable file
·78 lines (65 loc) · 2.09 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
#!/bin/bash
# Sync Sway + waybar + Wayland tools
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh"
SWAY_DIRS=(sway waybar)
collect() {
log_info "Collecting Sway configs from system to repo..."
for dir in "${SWAY_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 "Sway configs collected to repo"
}
install() {
log_info "Installing Sway configs from repo to system..."
check_packages sway || log_warn "Some Sway packages missing (continuing anyway)"
for dir in "${SWAY_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 "Sway configs installed to system"
}
validate() {
log_info "Validating Sway config..."
if [[ ! -f "$CONFIG_DIR/sway/config" ]]; then
log_error "Sway config not found"
return 1
fi
if ! command -v sway &>/dev/null; then
log_warn "Sway not installed, skipping validation"
return 0
fi
# Sway validation requires a display, so just check file exists
if [[ -f "$CONFIG_DIR/sway/config" ]]; then
log_ok "Sway config file exists"
# Check for obvious syntax errors
if grep -qE '^\s*(include|set|bindsym|exec)' "$CONFIG_DIR/sway/config"; then
log_ok "Sway config appears valid (basic check)"
fi
fi
return 0
}
case "$1" in
--collect) collect ;;
--install) install ;;
--validate) validate ;;
*)
echo "Usage: $0 [--collect|--install|--validate]"
exit 1
;;
esac