forked from malbiruk/driftwm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·146 lines (123 loc) · 4.55 KB
/
install.sh
File metadata and controls
executable file
·146 lines (123 loc) · 4.55 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
# driftwm installer — downloads the latest release and installs system-wide.
# Usage:
# curl -fsSL https://raw.githubusercontent.com/malbiruk/driftwm/main/install.sh | sudo sh
# curl -fsSL https://raw.githubusercontent.com/malbiruk/driftwm/main/install.sh | sudo sh -s uninstall
set -e
PREFIX="${PREFIX:-/usr/local}"
BINDIR="$PREFIX/bin"
DATADIR="$PREFIX/share"
SYSCONFDIR="${SYSCONFDIR:-/etc}"
REPO="malbiruk/driftwm"
# Runtime libraries the binary links against.
RUNTIME_LIBS="libseat.so libdisplay-info.so libinput.so libgbm.so libxkbcommon.so"
red() { printf '\033[1;31m%s\033[0m\n' "$1"; }
green() { printf '\033[1;32m%s\033[0m\n' "$1"; }
bold() { printf '\033[1m%s\033[0m\n' "$1"; }
check_root() {
if [ "$(id -u)" -ne 0 ]; then
red "Error: must run as root (use sudo)."
exit 1
fi
}
detect_distro() {
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "$ID"
else
echo "unknown"
fi
}
check_runtime_deps() {
missing=""
for lib in $RUNTIME_LIBS; do
if ! ldconfig -p 2>/dev/null | grep -q "$lib"; then
missing="$missing $lib"
fi
done
if [ -n "$missing" ]; then
red "Missing runtime libraries:$missing"
echo ""
distro=$(detect_distro)
case "$distro" in
fedora|rhel|centos)
bold "Install with: sudo dnf install libseat libdisplay-info libinput mesa-libgbm libxkbcommon" ;;
ubuntu|debian|linuxmint|pop)
bold "Install with: sudo apt install libseat1 libdisplay-info-dev libinput10 libudev1 libgbm1 libxkbcommon0" ;;
arch|manjaro|endeavouros)
bold "Install with: sudo pacman -S seatd libdisplay-info libinput mesa libxkbcommon" ;;
*)
bold "Install the packages that provide:$missing" ;;
esac
exit 1
fi
}
do_install() {
check_root
bold "Checking runtime dependencies..."
check_runtime_deps
green "All runtime dependencies found."
bold "Fetching latest release..."
if ! command -v curl >/dev/null 2>&1; then
red "Error: curl is required."
exit 1
fi
RELEASE_URL=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" \
| grep '"browser_download_url"' \
| grep 'x86_64-linux\.tar\.gz' \
| head -1 \
| sed 's/.*"browser_download_url": *"\([^"]*\)".*/\1/')
if [ -z "$RELEASE_URL" ]; then
red "Error: could not find a release artifact."
red "Check https://github.com/$REPO/releases"
exit 1
fi
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
bold "Downloading $RELEASE_URL..."
curl -fSL "$RELEASE_URL" -o "$TMPDIR/release.tar.gz"
tar xzf "$TMPDIR/release.tar.gz" -C "$TMPDIR"
# Find the extracted directory
SRCDIR=$(find "$TMPDIR" -maxdepth 1 -type d -name 'driftwm-*' | head -1)
if [ -z "$SRCDIR" ]; then
red "Error: unexpected archive structure."
exit 1
fi
bold "Installing to $PREFIX..."
install -Dm755 "$SRCDIR/driftwm" "$BINDIR/driftwm"
install -Dm755 "$SRCDIR/driftwm-session" "$BINDIR/driftwm-session"
install -Dm644 "$SRCDIR/driftwm.desktop" "$DATADIR/wayland-sessions/driftwm.desktop"
install -Dm644 "$SRCDIR/driftwm-portals.conf" "$DATADIR/xdg-desktop-portal/driftwm-portals.conf"
if [ ! -f "$SYSCONFDIR/driftwm/config.toml" ]; then
install -Dm644 "$SRCDIR/config.toml" "$SYSCONFDIR/driftwm/config.toml"
else
bold "Keeping existing $SYSCONFDIR/driftwm/config.toml"
fi
for f in "$SRCDIR"/wallpapers/*.glsl; do
[ -f "$f" ] && install -Dm644 "$f" "$DATADIR/driftwm/wallpapers/$(basename "$f")"
done
green "driftwm installed successfully!"
echo ""
echo " Binary: $BINDIR/driftwm"
echo " Session: $BINDIR/driftwm-session"
echo " Config: $SYSCONFDIR/driftwm/config.toml"
echo " Wallpapers: $DATADIR/driftwm/wallpapers/"
echo ""
echo "Select 'driftwm' from your display manager, or run 'driftwm' from a TTY."
}
do_uninstall() {
check_root
bold "Uninstalling driftwm..."
rm -f "$BINDIR/driftwm"
rm -f "$BINDIR/driftwm-session"
rm -f "$DATADIR/wayland-sessions/driftwm.desktop"
rm -f "$DATADIR/xdg-desktop-portal/driftwm-portals.conf"
rm -rf "$DATADIR/driftwm"
# Don't remove config — user may want to keep it
green "driftwm uninstalled. Config left at $SYSCONFDIR/driftwm/"
}
case "${1:-install}" in
install) do_install ;;
uninstall) do_uninstall ;;
*) red "Usage: $0 [install|uninstall]"; exit 1 ;;
esac