-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patheos-download-wallpapers
More file actions
executable file
·98 lines (84 loc) · 3.35 KB
/
eos-download-wallpapers
File metadata and controls
executable file
·98 lines (84 loc) · 3.35 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
#!/bin/bash
# Copy additional wallpapers from Github or Gitlab EOS site.
Main() {
local -r gitlab="https://gitlab.com/endeavouros-filemirror/Community-wallpapers/-/archive/main/Community-wallpapers-main.zip"
local -r github="https://github.com/EndeavourOS-Community-Editions/Community-wallpapers/archive/refs/heads/main.zip"
local url="$gitlab"
source /etc/eos-script-lib-yad.conf || return 1
case "$EOS_FILESERVER_SITE" in
github) url="$github" ;;
gitlab) ;;
*) DIE "value '$EOS_FILESERVER_SITE' of variable EOS_FILESERVER_SITE is not supported." ;;
esac
local progname=${0##*/}
local workdir=""
local dirtodel=""
local backup=no
local -r walldir=/usr/share/endeavouros/backgrounds
local -r zipdir=Community-wallpapers-main
local dloader=wget
Options "$@"
if [ "$workdir" ] ; then
# user managed $workdir
[ -d "$workdir" ] || DIE "working directory '$workdir' does not exist."
[ -w "$workdir" ] || DIE "working directory '$workdir' cannot be written."
else
# temporary $workdir
workdir=$(mktemp -d) || DIE "cannot create a working directory under '/tmp'."
chmod go-rwx "$workdir"
dirtodel="$workdir"
fi
echo "Downloading wallpapers, please wait ..." >&2
case "$dloader" in
wget) wget -O "$workdir"/Community-wallpapers.zip "$url" || DIE "wget failed, code $?" ;;
curl) curl -Lm 300 -o "$workdir"/Community-wallpapers.zip "$url" || DIE "curl failed, code $?" ;;
esac
echo "Moving wallpapers under $walldir ..." >&2
unzip -qd "$workdir" "$workdir"/Community-wallpapers.zip || exit 1
rm -f "$workdir"/Community-wallpapers.zip
rm -f "$workdir/$zipdir"/{community-wallpapers.png,README.md}
rm -rf "$workdir/$zipdir"/scripts
if [ $backup = yes ] ; then
sudo rm -rf $walldir/eos_wallpapers_{classic,community}.bak
sudo mv $walldir/eos_wallpapers_classic $walldir/eos_wallpapers_classic.bak
sudo mv $walldir/eos_wallpapers_community $walldir/eos_wallpapers_community.bak
else
sudo rm -rf $walldir/{eos_wallpapers_classic,eos_wallpapers_community}
fi
sudo cp -r "$workdir/$zipdir"/eos_wallpapers_* $walldir/ || exit 1
if [ "$dirtodel" = "$workdir" ] ; then
rm -rf "$workdir"
else
rm -rf "$workdir/$zipdir"
fi
}
Options() {
local arg
for arg in "$@" ; do
case "$arg" in
--github) url="${URLs[github]}" ;;
--gitlab) url="${URLs[gitlab]}" ;;
--wget) dloader=wget ;;
--curl) dloader=curl ;;
--backup) backup=yes ;;
--workdir=*) workdir="${arg#*=}" ;;
-h | --help) Help 0 ;;
*) DIE "parameter '$arg' is not supported." ;;
esac
done
}
Help() {
cat <<EOF
Usage: $progname [options]
Options: -h, --help This help.
--gitlab Download wallpapers from EndeavourOS pages at gitlab (default).
--github Download wallpapers from EndeavourOS pages at github.
--wget Use wget to download wallpapers (default).
--curl Use curl to download wallpapers.
--backup Backup existing wallpapers to $walldir/*.bak.
Default: no backups made.
EOF
[ "$1" ] && exit $1
}
DIE() { echo "$progname: error: $1" >&2; Help 1; }
Main "$@"