diff --git a/bin/gnome-extension-install b/bin/gnome-extension-install new file mode 100644 index 0000000..7d84f01 --- /dev/null +++ b/bin/gnome-extension-install @@ -0,0 +1,34 @@ +#!/bin/bash +declare globalGnomeExtensionDir='/usr/share/gnome-shell/extensions/' +declare localGnomeExtensionDir='~/.local/share/gnome-shell/extensions/' +declare usedExtensionDir="${localGnomeExtensionDir}" + +[[ -z "$@" ]] && { + echo "Syntax: $(basename $0) gnome-extension.zip {options}" + echo "-g install global to system (all-users)" + exit; +} + +declare extId=$(unzip -p "$1" metadata.json | grep uuid | cut -d \" -f4); + +[[ -z "${extId}" ]] && { + echo "Error: Invalid ZIP/Gnome-Extension, cannot determine extension-uuid from metadatan.json!"; + exit 1; +} + +[[ " $@ " =~ " -g " ]] && { + usedExtensionDir="${globalGnomeExtensionDir}"; +} + +mkdir -p "${usedExtensionDir}/${extId}/" || exit 1; +unzip -qu "$1" -d "${usedExtensionDir}/${extId}/" || exit 1; + + +[[ $(which gnome-shell-extension-tool > /dev/null) ]] && { + gnome-shell-extension-tool -e ${extId} || exit $?; +} || { + gnome-extensions enable ${extId} || exit $?; +} + +echo +echo "Success!"