Skip to content

Instantly share code, notes, and snippets.

@itoshkov
Last active November 16, 2016 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itoshkov/865fa42e4f53e0e7dd399c04216fa323 to your computer and use it in GitHub Desktop.
Save itoshkov/865fa42e4f53e0e7dd399c04216fa323 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Download and install the latest Papirus Icon theme
#set -x
set -e
DL_URL="https://github.com/PapirusDevelopmentTeam/papirus-icon-theme-gtk/archive/master.zip"
TARGET_DIR=$HOME/.icons
HASH_FILE=$TARGET_DIR/.papirus-icons.etag
get_remote_hash() {
curl -i -s -I -L $DL_URL | grep -i '^ETag: '
}
get_local_hash() {
touch $HASH_FILE
cat $HASH_FILE
}
extract() {
if [ -x /usr/bin/7z ]; then
/usr/bin/7z x "$1" -o"$2"
else
/usr/bin/unzip "$1" -d "$2"
fi
}
echo "Papirus icon theme for GTK"
mkdir -p $TARGET_DIR
echo "Comparing versions ..."
REMOTE_HASH=$(get_remote_hash)
LOCAL_HASH=$(get_local_hash)
if [ "$REMOTE_HASH" == "$LOCAL_HASH" ]
then
echo "Already using the latest version"
exit 0
fi
echo "Download new version from GitHub ..."
TEMP_DIR=$(mktemp -d)
curl -L $DL_URL -o $TEMP_DIR/master.zip
echo "Unpack archive ..."
extract $TEMP_DIR/master.zip $TEMP_DIR
echo "Delete old Papirus icon theme ..."
rm -rf $TARGET_DIR/{Papirus-GTK,Papirus-Dark-GTK}
echo "Installing ..."
mv $TEMP_DIR/papirus-icon-theme-gtk-master/{Papirus-GTK,Papirus-Dark-GTK} $TARGET_DIR
echo -n "$REMOTE_HASH" > $HASH_FILE
echo "Delete cache ..."
rm -rf $TEMP_DIR
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment