Update Ricing/Windows-7-Theme/install-win7-theme.sh
This commit is contained in:
@@ -7,47 +7,37 @@
|
|||||||
# ./install-win7-theme.sh
|
# ./install-win7-theme.sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
BASE_URL="https://scripts.gabesville.com/Gabesville/Debian-Linux/raw/branch/main/Ricing/Windows-7-Theme"
|
BASE_URL="https://scripts.gabesville.com/Gabesville/Debian-Linux/raw/branch/main/Ricing/Windows-7-Theme"
|
||||||
|
|
||||||
# filename -> destination dot-folder
|
# filename -> destination dot-folder
|
||||||
declare -A PACKAGES=(
|
declare -A PACKAGES=(
|
||||||
["Windows-7-theme.zip"]="$HOME/.themes"
|
["Windows-7-theme.zip"]="$HOME/.themes"
|
||||||
["Windows-7-icons.zip"]="$HOME/.icons"
|
["Windows-7-icons.zip"]="$HOME/.icons"
|
||||||
)
|
)
|
||||||
|
|
||||||
WORKDIR="$(mktemp -d)"
|
WORKDIR="$(mktemp -d)"
|
||||||
trap 'rm -rf "$WORKDIR"' EXIT
|
trap 'rm -rf "$WORKDIR"' EXIT
|
||||||
|
|
||||||
command -v unzip >/dev/null 2>&1 || { echo "unzip is required. Install it with: sudo apt install unzip" >&2; exit 1; }
|
command -v unzip >/dev/null 2>&1 || { echo "unzip is required. Install it with: sudo apt install unzip" >&2; exit 1; }
|
||||||
command -v curl >/dev/null 2>&1 || { echo "curl is required. Install it with: sudo apt install curl" >&2; exit 1; }
|
command -v curl >/dev/null 2>&1 || { echo "curl is required. Install it with: sudo apt install curl" >&2; exit 1; }
|
||||||
|
|
||||||
for zipname in "${!PACKAGES[@]}"; do
|
for zipname in "${!PACKAGES[@]}"; do
|
||||||
dest="${PACKAGES[$zipname]}"
|
dest="${PACKAGES[$zipname]}"
|
||||||
url="${BASE_URL}/${zipname}"
|
url="${BASE_URL}/${zipname}"
|
||||||
extract_dir="${WORKDIR}/${zipname%.zip}"
|
extract_dir="${WORKDIR}/${zipname%.zip}"
|
||||||
|
|
||||||
echo "==> Downloading ${zipname}..."
|
echo "==> Downloading ${zipname}..."
|
||||||
curl -fL --progress-bar -o "${WORKDIR}/${zipname}" "$url"
|
curl -fL --progress-bar -o "${WORKDIR}/${zipname}" "$url"
|
||||||
|
|
||||||
echo "==> Extracting ${zipname}..."
|
echo "==> Extracting ${zipname}..."
|
||||||
mkdir -p "$extract_dir"
|
mkdir -p "$extract_dir"
|
||||||
unzip -q "${WORKDIR}/${zipname}" -d "$extract_dir"
|
unzip -q "${WORKDIR}/${zipname}" -d "$extract_dir"
|
||||||
|
|
||||||
mkdir -p "$dest"
|
mkdir -p "$dest"
|
||||||
|
|
||||||
# Figure out whether the zip already contains a single top-level folder
|
src="$extract_dir"
|
||||||
# (e.g. "Windows 7/") or a bunch of loose files/folders at the root.
|
|
||||||
# If it's a single folder, move that folder's *contents* straight into
|
|
||||||
# the dot-folder so we don't end up with an unnecessary nested dir.
|
|
||||||
mapfile -t top_level < <(find "$extract_dir" -mindepth 1 -maxdepth 1)
|
|
||||||
|
|
||||||
if [[ ${#top_level[@]} -eq 1 && -d "${top_level[0]}" ]]; then
|
|
||||||
src="${top_level[0]}"
|
|
||||||
else
|
|
||||||
src="$extract_dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "==> Installing into ${dest}..."
|
echo "==> Installing into ${dest}..."
|
||||||
for item in "$src"/*; do
|
for item in "$src"/*; do
|
||||||
name="$(basename "$item")"
|
name="$(basename "$item")"
|
||||||
@@ -58,7 +48,7 @@ for zipname in "${!PACKAGES[@]}"; do
|
|||||||
fi
|
fi
|
||||||
mv "$item" "$target"
|
mv "$item" "$target"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "==> ${zipname} installed to ${dest}"
|
echo "==> ${zipname} installed to ${dest}"
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user