-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
99 lines (81 loc) · 2.2 KB
/
install.sh
File metadata and controls
99 lines (81 loc) · 2.2 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
#!/bin/sh
set -e
# ANSI color codes (set blank if not in a TTY)
if [ -t 1 ]; then
GREEN='\033[0;32m'
RED='\033[0;31m'
RESET='\033[0m'
else
GREEN=''
RED=''
RESET=''
fi
json=$(curl -s https://api.github.com/repos/yz778/hyprfloat/releases/latest)
VERSION=$(echo "$json" | grep -oP '"name":\s*"\K[^"]+')
TARBALL_URL=$(echo "$json" | grep -oP '"tarball_url":\s*"\K[^"]+')
INSTALL_HOME="${INSTALL_HOME:-$HOME/.local/share}"
CONFIG_HOME="${CONFIG_HOME:-$HOME/.config/hypr}"
BIN_DIR="${BIN_DIR:-$HOME/.local/bin}"
check_prerequisites() {
printf " - Checking dependencies"
for cmd in curl tar lua; do
if ! command -v "$cmd" >/dev/null; then
printf ": ${RED}$cmd is not installed${RESET}\n"
exit 1
fi
done
for lib in posix cjson; do
if ! lua -l $lib -e "" 2>/dev/null; then
printf ": ${RED}lua-$lib is not installed${RESET}\n"
exit 1
fi
done
printf " ... ${GREEN}OK${RESET}\n"
}
download() {
printf " - Downloading hyprfloat ($VERSION)"
TMP_DIR=$(mktemp -d)
if ! curl -sL "$TARBALL_URL" | tar -xz -C "$TMP_DIR" --strip-components=1 2>/dev/null; then
printf ": ${RED}download failed${RESET}\n"
exit 1
fi
printf " ... ${GREEN}OK${RESET}\n"
}
install_files() {
local INSTALL_DIR="$INSTALL_HOME/hyprfloat"
printf " - Installing $INSTALL_DIR "
printf "${RED}"
mkdir -p "$INSTALL_DIR"
cp -r "$TMP_DIR/src/." "$INSTALL_HOME/hyprfloat/"
printf "${RESET}"
printf "... ${GREEN}OK${RESET}\n"
printf " - Installing $BIN_DIR/hyprfloat "
printf "${RED}"
ln -sf "$INSTALL_DIR/hyprfloat" "$BIN_DIR/hyprfloat"
printf "${RESET}"
printf "... ${GREEN}OK${RESET}\n"
}
check_version() {
printf " - Verifying"
if output=$(hyprfloat version); then
printf ": $output ... ${GREEN}OK${RESET}\n"
else
printf " ${RED}failed${RESET}\n"
exit 1
fi
}
cleanup() {
rm -rf "$TMP_DIR"
}
#### MAIN
trap cleanup EXIT INT TERM
echo "Installing hyprfloat"
check_prerequisites
download
install_files
check_version
echo "Done"
echo "
To get started, you can install the default configuration by running:
hyprfloat install-config
"