-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallpapers.sh
executable file
·62 lines (53 loc) · 2.45 KB
/
wallpapers.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
#!/bin/bash
# Checking if the script is running as root.
if [ "$(id -u)" -ne 0 ]; then
dialog --title "Permission Denied" --msgbox "Please run this script as root via 'sudo' or 'su'. Thanks." 5 65
exit 1
fi
# Define an array of wallpaper URLs.
wallpaper_urls=(
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0011.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0023.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0036.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0037.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0042.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0057.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0058.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0065.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0076.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0188.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0230.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0256.jpg"
"https://gitlab.com/dwt1/wallpapers/-/raw/master/0257.jpg"
"https://raw.githubusercontent.com/ghostbsd/ghostbsd-wallpapers/master/Field_Of_Lightning.jpg"
"https://raw.githubusercontent.com/ghostbsd/ghostbsd-wallpapers/master/Lake_View.jpg"
"https://raw.githubusercontent.com/ghostbsd/ghostbsd-wallpapers/master/Mountain_View.jpg"
"https://raw.githubusercontent.com/ghostbsd/ghostbsd-wallpapers/master/Wood_Trail.jpg"
)
# Destination directory for wallpapers.
wallpaper_dir="/usr/share/wallpapers"
mkdir -p $wallpaper_dir
# Initialize a counter for the progress bar.
count=0
# Calculate the total number of wallpapers to download.
total_wallpapers=${#wallpaper_urls[@]}
# Create a function to download wallpapers and update the progress bar.
download_wallpapers() {
for url in "${wallpaper_urls[@]}"; do
filename="$(basename "$url")"
curl -s -L "$url" -o "$wallpaper_dir/$filename"
count=$((count + 1))
percent=$((count * 100 / total_wallpapers))
echo "$percent"
done
}
# Use dialog to create a progress bar.
dialog --title "Downloading Wallpapers" --gauge "Downloading wallpapers..." 10 50 < <(
download_wallpapers
)
# Check if any errors occurred during the download.
if [ $? -ne 0 ]; then
dialog --title "Error" --msgbox "An error occurred while downloading wallpapers." 10 40
exit 1
fi
dialog --title "Download Complete" --msgbox "Wallpapers downloaded and saved to $wallpaper_dir." 10 40