#!/bin/bash
commandName=gnome-shell-extension-installer;
extensionLocation=/usr/share/gnome-shell/extensions;
workingDirectory="$(pwd)";
contextRoot="$(mktemp -d)";
cd "$contextRoot";
sudo apt install -y jq;

wget -O "$commandName" "https://github.com/brunelli/gnome-shell-extension-installer/raw/master/gnome-shell-extension-installer";
sudo install "$commandName" /usr/local/bin;

cd "$workingDirectory";
rm -rf "$contextRoot";

for id in 779 4907 1162
do
    workingDirectory="$(pwd)";
    contextRoot="$(mktemp -d)";
    unzipLocation="$(mktemp -d)";
    cd "$contextRoot";

    gnome-shell-extension-installer "$id" --no-install;
    sudo gnome-shell-extension-installer "$id" --yes;
    unzip ./*.zip -d "$unzipLocation";
    uuid="$(jq -r '.uuid' "$unzipLocation/metadata.json")";

    sudo chmod -R +r "$extensionLocation/$uuid";
    gnome-extensions enable "$uuid";

    cd "$workingDirectory";
    rm -rf "$contextRoot";
done

killall -SIGQUIT gnome-shell;