Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save heisvoid/4b5487032efdd1d233b09580c48a189a to your computer and use it in GitHub Desktop.

Select an option

Save heisvoid/4b5487032efdd1d233b09580c48a189a to your computer and use it in GitHub Desktop.
#!/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