forked from ChrisTitusTech/dwm-titus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·355 lines (311 loc) · 14.1 KB
/
setup.sh
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#!/bin/sh
# Check for sudo or doas
if command -v sudo > /dev/null 2>&1; then
SUDO="sudo"
elif command -v doas > /dev/null 2>&1; then
SUDO="doas"
else
echo "Neither sudo nor doas found. Please install one of them and try again."
exit 1
fi
# Check for root privileges
if ! $SUDO -v; then
echo "This script requires sudo or doas privileges. Please run with appropriate permissions."
exit 1
fi
# Function to handle errors
handle_error() {
echo "Error: $1"
exit 1
}
# Function to install dependencies for Debian-based distributions
install_debian() {
$SUDO apt update || handle_error "Failed to update package lists"
# Check if Xorg is installed
if ! dpkg -s xserver-xorg x11-xserver-utils xinit >/dev/null 2>&1; then
echo "Xorg not found. Installing Xorg and related packages..."
$SUDO apt install -y xserver-xorg x11-xserver-utils xinit || handle_error "Failed to install Xorg and related packages"
else
echo "Xorg and related packages are already installed."
fi
$SUDO apt install -y libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libepoxy-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev cmake libxft-dev libimlib2-dev libxinerama-dev libxcb-res0-dev alsa-utils xfce4-power-manager make mate-polkit dunst flameshot || handle_error "Failed to install dependencies"
# Check if Github directory exists
if [ ! -d ~/Github ]; then
mkdir -p ~/Github || handle_error "Failed to create Github directory"
fi
cd ~/Github || handle_error "Failed to change directory to Github"
# Check if brillo is installed
if ! brillo -V >/dev/null 2>&1; then
echo "Brillo not found. Installing..."
if [ ! -d brillo ]; then
git clone https://github.com/CameronNemo/brillo.git || handle_error "Failed to clone brillo repository"
cd brillo || handle_error "Failed to change directory to brillo"
$SUDO make || handle_error "Failed to build brillo"
$SUDO make install || handle_error "Failed to install brillo"
cd .. || handle_error "Failed to return to parent directory"
else
echo "Brillo is already cloned, skipping clone."
fi
else
echo "Brillo is already installed."
fi
# Check if simple-usb-automount is installed
if ! simple-usb-automount -V >/dev/null 2>&1; then
echo "simple-usb-automount not found. Installing..."
if [ ! -d simple-usb-automount ]; then
git clone https://github.com/antonilol/simple-usb-automount.git || handle_error "Failed to clone simple-usb-automount repository"
cd simple-usb-automount || handle_error "Failed to change directory to simple-usb-automount"
$SUDO ./install || handle_error "Failed to install simple-usb-automount"
cd .. || handle_error "Failed to return to parent directory"
else
echo "simple-usb-automount is already cloned, skipping clone."
fi
else
echo "simple-usb-automount is already installed."
fi
# Return to original directory
cd - || handle_error "Failed to return to original directory"
}
# Function to install dependencies for Red Hat-based distributions
install_redhat() {
$SUDO yum groupinstall -y "Development Tools" || handle_error "Failed to install Development Tools"
# Check if Xorg is installed
if ! rpm -q xorg-x11-server-Xorg xorg-x11-xinit >/dev/null 2>&1; then
echo "Xorg not found. Installing Xorg and related packages..."
$SUDO yum install -y xorg-x11-server-Xorg xorg-x11-xinit xsetroot || handle_error "Failed to install Xorg and related packages"
else
echo "Xorg and related packages are already installed."
fi
$SUDO yum install -y dbus-devel gcc git libconfig-devel libdrm-devel libev-devel libX11-devel libX11-xcb libXext-devel libxcb-devel libGL-devel libEGL-devel libepoxy-devel meson ninja-build pcre2-devel pixman-devel uthash-devel xcb-util-image-devel xcb-util-renderutil-devel xorg-x11-proto-devel xcb-util-devel cmake libXft-devel imlib2-devel libXinerama-devel alsa-utils xfce4-power-manager make mate-polkit dunst flameshot || handle_error "Failed to install dependencies"
# Install brillo
# Check if brillo is installed
if ! brillo -V >/dev/null 2>&1; then
echo "Brillo not found. Proceeding with installation..."
if [ ! -d ~/Github ]; then
mkdir -p ~/Github || handle_error "Failed to create Github directory"
fi
cd ~/Github || handle_error "Failed to change directory to Github"
if [ ! -d brillo ]; then
git clone https://github.com/CameronNemo/brillo.git || handle_error "Failed to clone brillo repository"
cd brillo || handle_error "Failed to change directory to brillo"
make || handle_error "Failed to build brillo"
$SUDO make install || handle_error "Failed to install brillo"
cd .. || handle_error "Failed to return to parent directory"
else
echo "Brillo is already cloned, skipping installation."
fi
else
echo "Brillo is installed."
fi
# Check if simple-usb-automount is installed
if ! simple-usb-automount -V >/dev/null 2>&1; then
echo "simple-usb-automount not found. Proceeding with installation..."
if [ ! -d ~/Github ]; then
mkdir -p ~/Github || handle_error "Failed to create Github directory"
fi
cd ~/Github || handle_error "Failed to change directory to Github"
if [ ! -d simple-usb-automount ]; then
git clone https://github.com/antonilol/simple-usb-automount.git || handle_error "Failed to clone simple-usb-automount repository"
cd simple-usb-automount || handle_error "Failed to change directory to simple-usb-automount"
$SUDO ./install || handle_error "Failed to install simple-usb-automount"
cd .. || handle_error "Failed to return to parent directory"
else
echo "simple-usb-automount is already cloned, skipping installation."
fi
else
echo "simple-usb-automount is installed."
fi
}
# Function to install dependencies for Arch-based distributions
install_arch() {
$SUDO pacman -Syu --noconfirm || handle_error "Failed to update system"
# Check if Xorg is installed
if ! pacman -Qi xorg-server xorg-xsetroot xorg-xinit >/dev/null 2>&1; then
echo "Xorg not found. Installing Xorg and related packages..."
$SUDO pacman -S --noconfirm xorg-server xorg-xsetroot xorg-xinit || handle_error "Failed to install Xorg and related packages"
else
echo "Xorg and related packages are already installed."
fi
# Check if dependencies are installed
if ! pacman -Qi base-devel libconfig dbus libev libx11 libxcb libxext libgl libegl libepoxy meson ninja pcre2 pixman uthash xcb-util-image xcb-util-renderutil xorgproto cmake libxft imlib2 libxinerama libxcb xorg-xev alsa-utils pulseaudio-alsa xfce4-power-manager make mate-polkit dunst flameshot >/dev/null 2>&1; then
echo "Installing required dependencies..."
$SUDO pacman -S --noconfirm base-devel libconfig dbus libev libx11 libxcb libxext libgl libegl libepoxy meson ninja pcre2 pixman uthash xcb-util-image xcb-util-renderutil xorgproto cmake libxft libimlib2 libxinerama libxcb-res xorg-xev alsa-utils pulseaudio-alsa xfce4-power-manager make mate-polkit dunst flameshot || handle_error "Failed to install dependencies"
else
echo "All required dependencies are already installed."
fi
# AUR helper installation
if ! command -v yay > /dev/null 2>&1 && ! command -v paru > /dev/null 2>&1; then
echo "No AUR helper found. Installing yay..."
git clone https://aur.archlinux.org/yay.git || handle_error "Failed to clone yay repository"
cd yay || handle_error "Failed to change directory to yay"
makepkg -si --noconfirm || handle_error "Failed to install yay"
cd .. || handle_error "Failed to return to parent directory"
rm -rf yay
fi
# Install brillo using the available AUR helper
if command -v yay > /dev/null 2>&1; then
yay -S --noconfirm brillo simple-usb-automount-git || handle_error "Failed to install brillo"
elif command -v paru > /dev/null 2>&1; then
paru -S --noconfirm brillo simple-usb-automount-git || handle_error "Failed to install brillo"
else
echo "No AUR helper available. Skipping brillo installation."
fi
}
# Detect the distribution and install the appropriate packages
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
debian|ubuntu)
echo "Detected Debian-based distribution"
echo "Installing Dependencies using apt"
install_debian
;;
rhel|centos|fedora)
echo "Detected Red Hat-based distribution"
echo "Installing dependencies using Yellowdog Updater Modified"
install_redhat
;;
arch)
echo "Detected Arch-based distribution"
echo "Installing packages using pacman"
install_arch
;;
*)
handle_error "Unsupported distribution"
;;
esac
else
handle_error "OS ID cannot be found. Unsupported distribution"
fi
# Function to install Meslo Nerd font for dwm and rofi icons to work
install_nerd_font() {
FONT_DIR="~/.local/share/fonts"
FONT_ZIP="$FONT_DIR/Meslo.zip"
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
FONT_INSTALLED=$(fc-list | grep -i "Meslo")
# Check if Meslo Nerd-font is already installed
if [ -n "$FONT_INSTALLED" ]; then
echo "Meslo Nerd-fonts are already installed."
return 0
fi
echo "Installing Meslo Nerd-fonts"
# Create the fonts directory if it doesn't exist
if [ ! -d "$FONT_DIR" ]; then
mkdir -p "$FONT_DIR" || {
echo "Failed to create directory: $FONT_DIR"
return 1
}
else
echo "$FONT_DIR exists, skipping creation."
fi
# Check if the font zip file already exists
if [ ! -f "$FONT_ZIP" ]; then
# Download the font zip file
wget -P "$FONT_DIR" "$FONT_URL" || {
echo "Failed to download Meslo Nerd-fonts from $FONT_URL"
return 1
}
else
echo "Meslo.zip already exists in $FONT_DIR, skipping download."
fi
# Unzip the font file if it hasn't been unzipped yet
if [ ! -d "$FONT_DIR/Meslo" ]; then
unzip "$FONT_ZIP" -d "$FONT_DIR" || {
echo "Failed to unzip $FONT_ZIP"
return 1
}
else
echo "Meslo font files already unzipped in $FONT_DIR, skipping unzip."
fi
# Remove the zip file
rm "$FONT_ZIP" || {
echo "Failed to remove $FONT_ZIP"
return 1
}
# Rebuild the font cache
fc-cache -fv || {
echo "Failed to rebuild font cache"
return 1
}
echo "Meslo Nerd-fonts installed successfully"
}
picom_animations() {
# Clone the repository in the home/build directory
mkdir -p ~/build
if [ ! -d ~/build/picom ]; then
if ! git clone https://github.com/FT-Labs/picom.git ~/build/picom; then
echo "Failed to clone the repository"
return 1
fi
else
echo "Repository already exists, skipping clone"
fi
cd ~/build/picom || { echo "Failed to change directory to picom"; return 1; }
# Build the project
if ! meson setup --buildtype=release build; then
echo "Meson setup failed"
return 1
fi
if ! ninja -C build; then
echo "Ninja build failed"
return 1
fi
# Install the built binary
if ! $SUDO ninja -C build install; then
echo "Failed to install the built binary"
return 1
fi
echo "Picom animations installed successfully"
}
clone_config_folders() {
# Ensure the target directory exists
[ ! -d ~/.config ] && mkdir -p ~/.config
# Iterate over all directories in config/*
for dir in config/*/; do
# Extract the directory name
dir_name=$(basename "$dir")
# Clone the directory to ~/.config/
if [ -d "$dir" ]; then
cp -r "$dir" ~/.config/
echo "Cloned $dir_name to ~/.config/"
else
echo "Directory $dir_name does not exist, skipping"
fi
done
}
configure_backgrounds() {
# Set the variable BG_DIR to the path where backgrounds will be stored
BG_DIR="~/Pictures/backgrounds"
# Check if the ~/Pictures directory exists
if [ ! -d "~/Pictures" ]; then
# If it doesn't exist, print an error message and return with a status of 1 (indicating failure)
echo "Pictures directory does not exist"
mkdir ~/Pictures
echo "Directory was created in Home folder"
fi
# Check if the backgrounds directory (BG_DIR) exists
if [ ! -d "$BG_DIR" ]; then
# If the backgrounds directory doesn't exist, attempt to clone a repository containing backgrounds
if ! git clone https://github.com/ChrisTitusTech/nord-background.git ~/Pictures; then
# If the git clone command fails, print an error message and return with a status of 1
echo "Failed to clone the repository"
return 1
fi
# Rename the cloned directory to 'backgrounds'
mv ~/Pictures/nord-background ~/Pictures/backgrounds
# Print a success message indicating that the backgrounds have been downloaded
echo "Downloaded desktop backgrounds to $BG_DIR"
else
# If the backgrounds directory already exists, print a message indicating that the download is being skipped
echo "Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds"
fi
}
# Call the function
install_nerd_font
# Call the function
clone_config_folders
# Call the function
picom_animations
# Call the function
configure_backgrounds
echo "All dependencies installed successfully."