forked from mylinuxforwork/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-arch.sh
executable file
·155 lines (140 loc) · 4.12 KB
/
setup-arch.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
#!/bin/bash
clear
repo="quack-o/ml4w-dotfiles"
# Get latest tag from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$repo/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Get latest zip from GitHub
get_latest_zip() {
curl --silent "https://api.github.com/repos/$repo/releases/latest" | # Get latest release from GitHub api
grep '"zipball_url":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Check if package is installed
_isInstalled() {
package="$1";
check="$(sudo pacman -Qs --color always "${package}" | grep "local" | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
}
# Install required packages
_installPackages() {
toInstall=();
for pkg; do
if [[ $(_isInstalled "${pkg}") == 0 ]]; then
echo ":: ${pkg} is already installed.";
continue;
fi;
toInstall+=("${pkg}");
done;
if [[ "${toInstall[@]}" == "" ]]; then
# echo "All pacman packages are already installed.";
return;
fi;
printf "Package not installed:\n%s\n" "${toInstall[@]}";
sudo pacman --noconfirm -S "${toInstall[@]}";
}
# Required packages for the installer
packages=(
"wget"
"unzip"
"gum"
"rsync"
"git"
)
latest_version=$(get_latest_release)
# Some colors
GREEN='\033[0;32m'
NONE='\033[0m'
# Header
echo -e "${GREEN}"
cat <<"EOF"
____ __ ____
/ _/__ ___ / /____ _/ / /__ ____
_/ // _ \(_-</ __/ _ `/ / / -_) __/
/___/_//_/___/\__/\_,_/_/_/\__/_/
EOF
echo "ML4W Dotfiles for Hyprland"
echo -e "${NONE}"
while true; do
read -p "DO YOU WANT TO START THE INSTALLATION NOW? (Yy/Nn): " yn
case $yn in
[Yy]* )
echo ":: Installation started."
echo
break;;
[Nn]* )
echo ":: Installation canceled"
exit;
break;;
* )
echo ":: Please answer yes or no."
;;
esac
done
# Create Downloads folder if not exists
if [ ! -d ~/Downloads ]; then
mkdir ~/Downloads
echo ":: Downloads folder created"
fi
# Remove existing download folder and zip files
if [ -f $HOME/Downloads/dotfiles-main.zip ]; then
rm $HOME/Downloads/dotfiles-main.zip
fi
if [ -f $HOME/Downloads/dotfiles-dev.zip ]; then
rm $HOME/Downloads/dotfiles-dev.zip
fi
if [ -f $HOME/Downloads/dotfiles.zip ]; then
rm $HOME/Downloads/dotfiles.zip
fi
if [ -d $HOME/Downloads/dotfiles ]; then
rm -rf $HOME/Downloads/dotfiles
fi
if [ -d $HOME/Downloads/dotfiles_temp ]; then
rm -rf $HOME/Downloads/dotfiles_temp
fi
if [ -d $HOME/Downloads/dotfiles-main ]; then
rm -rf $HOME/Downloads/dotfiles-main
fi
if [ -d $HOME/Downloads/dotfiles-dev ]; then
rm -rf $HOME/Downloads/dotfiles-dev
fi
# Synchronizing package databases
sudo pacman -Sy
echo
# Install required packages
echo ":: Checking that required packages are installed..."
_installPackages "${packages[@]}";
echo
# Select the dotfiles version
echo "Please choose between: "
echo "- ML4W Dotfiles for Hyprland $latest_version (latest stable release)"
echo "- ML4W Dotfiles for Hyprland Rolling Release (main branch including the latest commits)"
echo
version=$(gum choose "main-release" "rolling-release" "CANCEL")
if [ "$version" == "main-release" ]; then
echo ":: Installing Main Release"
yay -S --noconfirm ml4w-hyprland
elif [ "$version" == "rolling-release" ]; then
echo ":: Installing Rolling Release"
yay -S ml4w-hyprland-git
elif [ "$version" == "CANCEL" ]; then
echo ":: Setup canceled"
exit 130
else
echo ":: Setup canceled"
exit 130
fi
echo ":: Installation complete."
echo
# Start Spinner
gum spin --spinner dot --title "Starting setup now..." -- sleep 3
# Start setup
bin/ml4w-hyprland-setup -p arch