-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer
executable file
·184 lines (158 loc) · 6.17 KB
/
installer
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
#!/usr/bin/env bash
# Define text colors
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
GREEN=$(tput setaf 2)
BLUE=$(tput setaf 4)
BOLD=$(tput bold)
RESET=$(tput sgr0)
# Define success message with green color
OK='\n\033[0;32m OK...\033[0m'
# Function to display a stylized logo
logo() {
local text="${1:?}"
echo -en "
███████╗██╗░░░░░███╗░░░███╗███████╗██████╗░
██╔════╝██║░░░░░████╗░████║██╔════╝██╔══██╗
█████╗░░██║░░░░░██╔████╔██║█████╗░░██████╔╝
██╔══╝░░██║░░░░░██║╚██╔╝██║██╔══╝░░██╔══██╗
███████╗███████╗██║░╚═╝░██║███████╗██║░░██║
╚══════╝╚══════╝╚═╝░░░░░╚═╝╚══════╝╚═╝░░╚═╝
SCRIPT\n\n"
printf ' %s [%s%s %s%s %s]%s\n\n' "${RED}" "${RESET}" "${YELLOW}" "${text}" "${RESET}" "${RED}" "${RESET}"
sleep 2
}
# Check if the script is run as root
if [ "$(id -u)" = 0 ]; then
echo "This script MUST NOT be run as root user."
exit 1
fi
# Display welcome message
logo "Welcome! ${USER}"
printf '%sThis script will install needed dependencies and copy my dotfiles to your bspwm setup.%s\n\nThis installer script does NOT change any configuration of your system.\nIts just a script that copies and moves my dotfiles to your ~/.config directory\n\n' "${RED}" "${RESET}"
sleep 5
# Ask for user confirmation to continue
while true; do
read -rp " Do you wish to continue? [Yy/Nn]: " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) printf " Error: just write 'y' or 'n'\n\n";;
esac
done
clear
# Display logo for installing needed packages
logo "Installing needed packages..."
# List of dependencies
dependencies=(base-devel pacman-contrib bspwm polybar sxhkd alacritty dunst rofi lsd jq polkit-gnome playerctl mpd ncmpcpp ranger mpc picom feh ueberzug maim pamixer libwebp webp-pixbuf-loader xorg-xprop xorg-xkill papirus-icon-theme ttf-jetbrains-mono ttf-jetbrains-mono-nerd ttf-terminus-nerd ttf-inconsolata ttf-joypixels zsh neofetch)
# Function to check if a package is installed
is_installed() {
pacman -Qi "$1" &> /dev/null
return $?
}
# Print message for checking required packages
printf "%s%sChecking for required packages...%s\n" "${BOLD}" "${BLUE}" "${RESET}"
# Loop through dependencies and install if needed
for package in "${dependencies[@]}"; do
if ! is_installed "$package"; then
sudo pacman -S "$package" --noconfirm
printf "\n"
else
printf '%s%s is already installed on your system!%s\n' "${GREEN}" "$package" "${RESET}"
sleep 1
fi
done
sleep 2
clear
# Display logo for checking if yay is installed
logo "Checking if yay is installed"
# Check if yay is installed, if not, install it
if ! command -v yay &> /dev/null; then
printf "%s%sError YAY is not installed%s\n" "${BOLD}" "${RED}" "${RESET}"
sleep 1
printf "%s%sInstalling YAY..%s\n\n" "${BOLD}" "${YELLOW}" "${RESET}"
sleep 1
git clone https://aur.archlinux.org/yay.git
cd yay || exit
makepkg -si
cd "$HOME" || exit
rm -rf yay
else
printf "%s%sYAY is already installed on your system%s\n" "${BOLD}" "${GREEN}" "${RESET}"
fi
sleep 2
clear
# Display logo for cloning dotfiles
logo "Cloning DotFiles!"
[ -d ~/arch-dotfiles ] && rm -rf ~/arch-dotfiles
printf "Cloning dotfiles from https://github.com/elmerginez/arch-dotfiles.git\n\n"
cd "$HOME" || exit
git clone --depth 1 https://github.com/elmerginez/arch-dotfiles.git
sleep 2
clear
# Display logo for copying config
logo "Copying Config..."
printf "Copying files to respective directories..\n"
# Copy configuration files to the appropriate directories
if [ ! -d "$HOME/.config" ]; then
mkdir -p "$HOME/.config"
cp -Rf "$HOME/arch-dotfiles/config/"* "$HOME/.config/"
else
cp -Rf "$HOME/arch-dotfiles/config/"* "$HOME/.config/"
fi
# Copy binary files
if [ ! -d "$HOME/.local/bin" ]; then
mkdir -p "$HOME/.local/bin"
cp -Rf "$HOME/arch-dotfiles/misc/bin/"* "$HOME/.local/bin/"
else
cp -Rf "$HOME/arch-dotfiles/misc/bin/"* "$HOME/.local/bin/"
fi
# Copy applications files
if [ ! -d "$HOME/.local/share/applications" ]; then
mkdir -p "$HOME/.local/share/applications"
cp -Rf "$HOME/arch-dotfiles/misc/applications/"* "$HOME/.local/share/applications/"
else
cp -Rf "$HOME/arch-dotfiles/misc/applications/"* "$HOME/.local/share/applications/"
fi
# Copy ASCII art files
if [ ! -d "$HOME/.local/share/asciiart" ]; then
mkdir -p "$HOME/.local/share/asciiart"
cp -Rf "$HOME/arch-dotfiles/misc/asciiart/"* "$HOME/.local/share/asciiart/"
else
cp -Rf "$HOME/arch-dotfiles/misc/asciiart/"* "$HOME/.local/share/asciiart/"
fi
# Copy font files
if [ ! -d "$HOME/.local/share/fonts" ]; then
mkdir -p "$HOME/.local/share/fonts"
cp -Rf "$HOME/arch-dotfiles/misc/fonts/"* "$HOME/.local/share/fonts/"
else
cp -Rf "$HOME/arch-dotfiles/misc/fonts/"* "$HOME/.local/share/fonts/"
fi
# Copy the main zshrc file
cp -f "$HOME/arch-dotfiles/home/.zshrc" "$HOME"
printf "%s%sFiles copied successfully!!%s\n" "${BOLD}" "${GREEN}" "${RESET}"
sleep 2
clear
# Display logo for installing packages from AUR
logo "Installing needed packages from AUR"
yay -S nerd-fonts-cozette-ttf scientifica-font --removemake --cleanafter
sleep 2
clear
# Display logo for reloading fonts
logo "Reloading fonts.."
fc-cache -rv >/dev/null 2>&1
printf "%s%sFonts reloaded successfully!%s\n" "${BOLD}" "${GREEN}" "${RESET}"
sleep 2
clear
# Display logo for enabling MPD service
logo "Enabling MPD service"
systemctl --user enable mpd.service
systemctl --user start mpd.service
printf "%s%sDone!!%s\n" "${BOLD}" "${GREEN}" "${RESET}"
sleep 2
clear
# Final message
logo "Installation finished"
printf "%s%sPlease reboot, then select bspwm in your login manager and log in.%s\n\n" "${BOLD}" "${RED}" "${RESET}"
chsh -s /usr/bin/zsh
zsh