Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·107 lines (89 loc) · 4.08 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·107 lines (89 loc) · 4.08 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
#!/bin/bash
# alight installer -- one command, no app, no UI.
#
# curl -fsSL https://raw.githubusercontent.com/PrivateVictories-Main/alight/main/install.sh | bash
#
# Apple Silicon only. Grabs the prebuilt arm64 binary from the latest
# release (no Xcode needed); falls back to building from source.
set -euo pipefail
REPO="PrivateVictories-Main/alight"
REPO_URL="${ALIGHT_REPO:-https://github.com/$REPO}"
# ----- presentation ----------------------------------------------------------
if [ -t 1 ]; then
BOLD=$'\033[1m'; DIM=$'\033[2m'; CYAN=$'\033[36m'
GREEN=$'\033[32m'; RED=$'\033[31m'; RESET=$'\033[0m'
else
BOLD=""; DIM=""; CYAN=""; GREEN=""; RED=""; RESET=""
fi
ok() { printf " %s✓%s %b\n" "$GREEN" "$RESET" "$1"; }
die() { printf "\n %s✗ %b%s\n\n" "$RED" "$1" "$RESET" >&2; exit 1; }
# spin "label" cmd... -> run cmd silently behind a spinner
spin() {
local label=$1; shift
local logf="$workdir/step.log"
("$@" >"$logf" 2>&1) &
local pid=$!
if [ -t 1 ]; then
local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏') i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %s%s%s %s" "$CYAN" "${frames[i]}" "$RESET" "$label"
i=$(( (i + 1) % 10 ))
sleep 0.08
done
printf "\r\033[K"
fi
if ! wait "$pid"; then
cp "$logf" /tmp/alight-install-error.log 2>/dev/null || true
die "${label} failed ${DIM}(log: /tmp/alight-install-error.log)${RESET}"
fi
}
printf "\n %s◆ alight%s %s— focus follows your pointer, invisibly%s\n\n" \
"$BOLD" "$RESET" "$DIM" "$RESET"
[ "$(uname -s)" = "Darwin" ] || die "alight is macOS-only"
[ "$(uname -m)" = "arm64" ] || die "alight is built exclusively for Apple Silicon"
workdir="$(mktemp -d /tmp/alight-install.XXXXXX)"
trap 'rm -rf "$workdir"' EXIT
bin="$workdir/alight"
# ----- fast path: prebuilt universal binary from the latest release ----------
asset_url="$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" 2>/dev/null \
| grep -o '"browser_download_url": *"[^"]*alight-macos[^"]*"' \
| head -1 | cut -d'"' -f4 || true)"
if [ -n "$asset_url" ]; then
spin "downloading alight" curl -fsSL -o "$bin" "$asset_url"
chmod +x "$bin"
ok "downloaded alight ${DIM}(prebuilt for Apple Silicon)${RESET}"
else
command -v swift >/dev/null 2>&1 || die \
"no prebuilt release reachable and no Swift toolchain to build with.\n Install the Xcode Command Line Tools first: ${BOLD}xcode-select --install${RESET}"
spin "downloading source" git clone --quiet --depth 1 "$REPO_URL" "$workdir/src"
ok "downloaded source"
spin "building release binary" swift build -c release --package-path "$workdir/src"
bin="$workdir/src/.build/release/alight"
ok "built release binary"
fi
# ----- install: binary copies itself, signs, bootstraps the LaunchAgent ------
if [ "${ALIGHT_DRY_RUN:-0}" = "1" ]; then
ok "dry run — stopping before LaunchAgent install"
exit 0
fi
out="$("$bin" install)" || die "install step failed"
ok "installed to ~/.local/bin/alight"
ok "daemon running — starts itself at every login"
# ~/.local/bin on PATH so `alight` works in new shells
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
*) if ! grep -qs '\.local/bin' "$HOME/.zshrc" 2>/dev/null; then
printf '\nexport PATH="$HOME/.local/bin:$PATH" # added by alight installer\n' >> "$HOME/.zshrc"
fi
ok "added ~/.local/bin to PATH ${DIM}(~/.zshrc — takes effect in new terminals)${RESET}"
;;
esac
if printf "%s" "$out" | grep -q "manual step"; then
printf "\n %sOne step left%s %s(macOS requires it for every window tool):%s\n" \
"$BOLD" "$RESET" "$DIM" "$RESET"
printf " System Settings %s→%s Privacy %s&%s Security %s→%s Accessibility %s→%s enable %salight%s\n" \
"$DIM" "$RESET" "$DIM" "$RESET" "$DIM" "$RESET" "$DIM" "$RESET" "$BOLD" "$RESET"
printf " %sit arms itself the moment it's granted — nothing to restart.%s\n" \
"$DIM" "$RESET"
fi
printf "\n %sTry:%s alight status alight delay 150 alight uninstall\n\n" "$BOLD" "$RESET"