Last active
October 26, 2018 16:36
-
-
Save heisvoid/4b5487032efdd1d233b09580c48a189a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Check available updates for extensions of Inox web browser. | |
| show_usage () | |
| { | |
| local name=`basename "$0"` | |
| cat << EOF | |
| Usage: $name [OPTIONS] -c CHROME_WEB_STORE_ITEM_PROPERTY_CLI | |
| Description: | |
| Check available updates for extensions of Inox. | |
| -i | |
| Assign the home of inoxunpack. | |
| \$HOME/.inoxunpack is default. | |
| -c | |
| Assign the chrome-web-store-item-property-cli. | |
| -h | |
| Show usage. | |
| EOF | |
| } | |
| inoxunpack="$HOME/.inoxunpack" | |
| cwsipc="" | |
| while getopts ":i:c:" option; do | |
| case "$option" in | |
| i) | |
| inoxunpack="$OPTARG" | |
| ;; | |
| c) | |
| cwsipc="$OPTARG" | |
| ;; | |
| *) | |
| show_usage | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| if [ -z "$cwsipc" ]; then | |
| echo "Error: The chrome-web-store-item-property-cli is not specified." >&2 | |
| echo "" | |
| show_usage | |
| exit 1 | |
| fi | |
| updates="" | |
| for ext in `ls -d $inoxunpack/* 2>/dev/null`; do | |
| ver_cur=`cat "$ext/manifest.json" 2>/dev/null | jq ".version"` | |
| if [ "null" == "$ver_cur" ]; then | |
| continue | |
| fi | |
| id=`basename "$ext"` | |
| prop=`"$cwsipc" "$id" 2>/dev/null` | |
| if [ 0 -ne "$?" ]; then | |
| continue | |
| fi | |
| ver_new=`echo "$prop" | jq ".version"` | |
| if [ "$ver_cur" != "$ver_new" ]; then | |
| name=`echo "$prop" | jq ".name"` | |
| if [ "null" != "$name" ]; then | |
| if [ -z "$updates" ]; then | |
| updates="$name" | |
| else | |
| updates="$updates\n$name" | |
| fi | |
| fi | |
| fi | |
| done | |
| if [ ! -z "$updates" ] | |
| then | |
| notify-send "Inox extension update available" "$updates" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment