-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·66 lines (51 loc) · 1.86 KB
/
install.sh
File metadata and controls
executable file
·66 lines (51 loc) · 1.86 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
#!/bin/bash
set -euo pipefail
die() {
printf 'Error: %s\n' "${1:-Unknown error}" >&2
exit 1
}
info() {
printf '%s\n' "$1"
}
# Resolve repo root (directory containing this script)
REPO_ROOT="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
SRC_DIR="$REPO_ROOT/src"
EXAMPLE_CONFIG="$REPO_ROOT/example-config.json"
EXAMPLE_WAYBAR_CONFIG="$REPO_ROOT/example-waybar-config.jsonc"
BIN_DIR="/usr/bin"
CONFIG_DIR="${HOME}/.config/bartop"
CONFIG_FILE="${CONFIG_DIR}/config.json"
WAYBAR_CONFIG_FILE="${CONFIG_DIR}/waybar-config.jsonc"
# Sanity checks
[[ -d "$SRC_DIR" ]] || die "Missing src/ directory"
[[ -f "$EXAMPLE_CONFIG" ]] || die "Missing example-config.json"
mkdir -p -- "$BIN_DIR"
mkdir -p -- "$CONFIG_DIR"
install_script() {
local src="$1"
local dst="$2"
[[ -f "$src" ]] || die "Missing script: $src"
install -m 0755 "$src" "$dst"
info "Installed $(basename "$dst") -> $dst"
}
# Install commands
install_script "$SRC_DIR/bartop.sh" "$BIN_DIR/bartop"
install_script "$SRC_DIR/bartop-poll.sh" "$BIN_DIR/bartop-poll"
install_script "$SRC_DIR/bartop-read.sh" "$BIN_DIR/bartop-read"
# Install default config if none already exists
if [[ ! -f "$CONFIG_FILE" ]]; then
install -m 0644 "$EXAMPLE_CONFIG" "$CONFIG_FILE"
info "Installed default config -> $CONFIG_FILE"
else
info "Config already exists, skipping default config install: $CONFIG_FILE"
fi
# Install default waybar-config if none already exists
if [[ ! -f "$WAYBAR_CONFIG_FILE" ]]; then
install -m 0644 "$EXAMPLE_WAYBAR_CONFIG" "$WAYBAR_CONFIG_FILE"
info "Installed default waybar config -> $CONFIG_FILE"
else
info "Waybar config already exists, skipping default config install: $WAYBAR_CONFIG_FILE"
fi
info "bartop installation complete"
info "Ensure $BIN_DIR is in your PATH"
info "Ensure $EXAMPLE_WAYBAR_CONFIG is included in your main waybar config file"