papirus-icon-theme/install.sh

105 lines
2.3 KiB
Bash
Raw Normal View History

2018-01-18 11:37:25 -05:00
#!/bin/sh
set -e
gh_repo="papirus-icon-theme"
gh_desc="Papirus icon theme"
cat <<- EOF
ppppp ii
pp pp aaaaa ppppp rr rrr uu uu sssss
ppppp aa aa pp pp ii rrrr uu uu ssss
pp aa aa pp pp ii rr uu uu ssss
pp aaaaa ppppp ii rr uuuuu sssss
pp
pp
$gh_desc
https://github.com/PapirusDevelopmentTeam/$gh_repo
EOF
2018-10-23 17:07:06 -04:00
: "${DESTDIR:=/usr/share/icons}"
: "${TAG:=master}"
: "${THEMES:=Papirus ePapirus Papirus-Dark Papirus-Light}"
: "${uninstall:=false}"
2018-01-18 11:37:25 -05:00
_msg() {
2019-11-19 06:34:03 -05:00
echo "=>" "$@"
2018-01-18 11:37:25 -05:00
}
_rm() {
# removes parent directories if empty
_sudo rm -rf "$1"
_sudo rmdir -p "$(dirname "$1")" 2>/dev/null || true
}
_sudo() {
if [ -w "$DESTDIR" ] || [ -w "$(dirname "$DESTDIR")" ]; then
"$@"
else
sudo "$@"
fi
}
_download() {
_msg "Getting the latest version from GitHub ..."
wget -O "$temp_file" \
2018-10-23 17:07:06 -04:00
"https://github.com/PapirusDevelopmentTeam/$gh_repo/archive/$TAG.tar.gz"
2018-01-18 11:37:25 -05:00
_msg "Unpacking archive ..."
tar -xzf "$temp_file" -C "$temp_dir"
}
_uninstall() {
for theme in "$@"; do
test -d "$DESTDIR/$theme" || continue
2018-01-18 11:37:25 -05:00
_msg "Deleting '$theme' ..."
_rm "$DESTDIR/$theme"
done
}
_install() {
_sudo mkdir -p "$DESTDIR"
for theme in "$@"; do
2018-10-23 17:07:06 -04:00
test -d "$temp_dir/$gh_repo-$TAG/$theme" || continue
2018-01-18 11:37:25 -05:00
_msg "Installing '$theme' ..."
2018-10-23 17:07:06 -04:00
_sudo cp -R "$temp_dir/$gh_repo-$TAG/$theme" "$DESTDIR"
2018-02-03 17:13:32 -05:00
_sudo cp -f \
2018-10-23 17:07:06 -04:00
"$temp_dir/$gh_repo-$TAG/AUTHORS" \
"$temp_dir/$gh_repo-$TAG/LICENSE" \
2018-02-03 17:13:32 -05:00
"$DESTDIR/$theme" || true
2018-01-18 11:37:25 -05:00
_sudo gtk-update-icon-cache -q "$DESTDIR/$theme" || true
done
# Try to restore the color of folders from a config
2019-11-19 06:34:03 -05:00
if command -v papirus-folders >/dev/null; then
papirus-folders -R || true
fi
2018-01-18 11:37:25 -05:00
}
_cleanup() {
_msg "Clearing cache ..."
rm -rf "$temp_file" "$temp_dir"
rm -f "$HOME/.cache/icon-cache.kcache"
_msg "Done!"
}
trap _cleanup EXIT HUP INT TERM
temp_file="$(mktemp -u)"
temp_dir="$(mktemp -d)"
if [ "$uninstall" = "false" ]; then
_download
_uninstall $THEMES
_install $THEMES
else
_uninstall $THEMES
fi