-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·91 lines (73 loc) · 2.34 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·91 lines (73 loc) · 2.34 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
#!/usr/bin/env bash
set -euo pipefail
info() { printf '[*] %s\n' "$*"; }
warn() { printf '[!] %s\n' "$*"; }
die() { printf '[x] %s\n' "$*" >&2; exit 1; }
REPO_ROOT="$(cd -- "$(dirname -- "$0")" && pwd)"
CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
BIN_HOME="${NIRI_UTILS_BIN_HOME:-$HOME/.local/bin}"
info "Installing niri-utils (user mode)..."
# -------------------------
# Dependencies (optional)
# -------------------------
if command -v pacman >/dev/null 2>&1; then
if [ "${NIRI_UTILS_SKIP_DEPS:-0}" != "1" ] && command -v sudo >/dev/null 2>&1; then
info "Installing dependencies..."
sudo pacman -S --needed \
gtklock \
gtklock-userinfo-module \
gtklock-powerbar-module \
imagemagick \
rust || warn "Dependency install failed (continuing...)"
else
info "Skipping dependency install"
fi
fi
# -------------------------
# Install niri-lock (SAFE)
# -------------------------
LOCK_DIR="$CONFIG_HOME/niri-lock"
info "Setting up niri-lock in $LOCK_DIR"
mkdir -p "$LOCK_DIR"
# copy only if not exists (safe)
[ -f "$LOCK_DIR/config.ini" ] || cp "$REPO_ROOT/niri-lock/config.ini" "$LOCK_DIR/"
[ -f "$LOCK_DIR/style.css" ] || cp "$REPO_ROOT/niri-lock/style.css" "$LOCK_DIR/"
cp "$REPO_ROOT/niri-lock/lock.sh" "$LOCK_DIR/"
chmod +x "$LOCK_DIR/lock.sh"
# fix style path
CONFIG_INI="$LOCK_DIR/config.ini"
STYLE_PATH="$LOCK_DIR/style.css"
if grep -q '^style=' "$CONFIG_INI" 2>/dev/null; then
sed -i "s|^style=.*$|style=$STYLE_PATH|" "$CONFIG_INI"
else
echo "style=$STYLE_PATH" >> "$CONFIG_INI"
fi
# -------------------------
# Build niri-idle
# -------------------------
command -v cargo >/dev/null || die "cargo not found"
info "Building niri-idle..."
(cd "$REPO_ROOT/niri-idle" && cargo build --release --locked)
# -------------------------
# Install binary
# -------------------------
info "Installing binary to $BIN_HOME"
mkdir -p "$BIN_HOME"
install -m 0755 \
"$REPO_ROOT/niri-idle/target/release/niri-idle" \
"$BIN_HOME/niri-idle"
# -------------------------
# PATH check
# -------------------------
if ! echo "$PATH" | grep -q "$BIN_HOME"; then
warn "$BIN_HOME is not in PATH"
warn "Add this to your shell config:"
echo "export PATH=\"$BIN_HOME:\$PATH\""
fi
# -------------------------
# Done
# -------------------------
info "Install complete"
echo
echo "Run: niri-idle"
echo "Lock script: ~/.config/niri-lock/lock.sh"