Skip to content

Instantly share code, notes, and snippets.

@eduncan911
Last active July 25, 2019 22:43
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 eduncan911/c4bb281682b4809304afe2b500751666 to your computer and use it in GitHub Desktop.
Save eduncan911/c4bb281682b4809304afe2b500751666 to your computer and use it in GitHub Desktop.
Gnome: Manually add several Extensions (or, for those that don't trust browser extensions)
#!/bin/bash -e
# A script to mass install Gnome extensions from a single folder.
#
# for global extensions, use /usr/share/gnome-shell/extensions/
EXTENSIONS_DIR=~/.local/share/gnome-shell/extensions
TMP_DIR="/tmp/gnome-install-extensions"
DIR=$1
# exit early, exit often
if [[ -z "${DIR}" ]]; then
echo "You must pass a directory. E.g. ${0} ~/Downloads"
exit 10
fi
rm -rf ${TMP_DIR}
mkdir -p ${EXTENSIONS_DIR} ${TMP_DIR}
pushd ${TMP_DIR} > /dev/null
for f in $(ls ${DIR}/*.shell-extension.zip); do
fn=$(basename -- "${f}")
local_dir="$(basename ${fn%.*})"
metadata="${local_dir}/metadata.json"
cp ${f} ${TMP_DIR}/${fn}
unzip -qq ${fn} -d ${local_dir}
[[ ! -f "${metadata}" ]] && echo "${metadata} not found, skipping" && continue
# get the UUID to name
name=$(grep -E "uuid" ${metadata} | sed 's/\"uuid\"\: \"//g' | sed 's/\",//g' )
# gnome extension dirs must name the uuid name in metadata.json above
mv ${local_dir} ${name}
rm ${fn}
cp -r * ${EXTENSIONS_DIR}/
done
popd > /dev/null
rm -rf ${TMP_DIR}
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment