diff --git a/modules/gnome-extensions/README.md b/modules/gnome-extensions/README.md new file mode 100644 index 0000000..214a9aa --- /dev/null +++ b/modules/gnome-extensions/README.md @@ -0,0 +1,24 @@ +# `gnome-extensions` + +The `gnome-extensions` module can be used to install Gnome extensions inside system directory. + +This module is universally compatible with all distributions which ship Gnome, as long as some extension doesn't require some additional dependency, like Pano. + +Thanks to https://extensions.gnome.org which provides end-releases of extensions as zips, it is very easy to maintain this module configuration. +Basically the only maintenance is to bump the extension version when new Fedora/Gnome releases (around every 6 months). + +What does this module do? +- It parses the gettext-domain that you inputted, along with the extension version +- It downloads the extension directly from https://extensions.gnome.org +- Downloaded extension archive is then extracted to temporary directory +- All of its extracted files are copied to the appropriate final directories + (`/usr/share/gnome-shell/extensions`, `/usr/share/glib-2.0/schemas`, & `/usr/share/locale`) + +# Usage + +To use this module, you need to input gettext-domain of the extension without @ symbol + the version of the extension in `.v%VERSION%` format. +You can see gettext-domain of the extension by looking at the extension repo inside metadata.json +or by simply downloading the zip file from https://extensions.gnome.org & than looking at the download URL part after `/extension-data/` & before `.v%VERSION%`. + +You must assure that version of the extension is compatible with current Gnome version that your image is using. +You can easily see this information when downloading extension from https://extensions.gnome.org diff --git a/modules/gnome-extensions/gnome-extensions.sh b/modules/gnome-extensions/gnome-extensions.sh new file mode 100644 index 0000000..9a65c0d --- /dev/null +++ b/modules/gnome-extensions/gnome-extensions.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -euo pipefail + +get_yaml_array GETTEXT_DOMAIN '.install.gettext-domain[]' "$1" + +if [[ ${#GETTEXT_DOMAIN[@]} -gt 0 ]]; then + for EXTENSION in "${GETTEXT_DOMAIN[@]}"; do + URL="https://extensions.gnome.org/extension-data/${EXTENSION}.shell-extension.zip" + TMP_DIR="/tmp/${EXTENSION}" + ARCHIVE=$(basename "${URL}") + ARCHIVE_DIR="${TMP_DIR}/${ARCHIVE}" + VERSION=$(echo "${EXTENSION}" | grep -oP 'v\d+') + echo "Installing ${EXTENSION} Gnome extension with version ${VERSION}" + # Download archive + curl -L "${URL}" --create-dirs -o "${ARCHIVE_DIR}" + # Extract archive + echo "Extracting ZIP archive" + unzip "${ARCHIVE_DIR}" -d "${TMP_DIR}" > /dev/null + # Remove archive + echo "Removing archive" + rm "${ARCHIVE_DIR}" + # Read necessary info from metadata.json + echo "Reading necessary info from metadata.json" + UUID=$(yq '.uuid' < "${TMP_DIR}/metadata.json") + SCHEMA_ID=$(yq '.settings-schema' < "${TMP_DIR}/metadata.json") + # Install main extension files + echo "Installing main extension files" + install -d -m 0755 "/usr/share/gnome-shell/extensions/${UUID}/" + find "${TMP_DIR}" -mindepth 1 -maxdepth 1 ! -path "*locale*" ! -path "*schemas*" -exec cp -r {} "/usr/share/gnome-shell/extensions/${UUID}/" \; + find "/usr/share/gnome-shell/extensions/${UUID}" -type d -exec chmod 0755 {} + + find "/usr/share/gnome-shell/extensions/${UUID}" -type f -exec chmod 0644 {} + + # Install schema + echo "Installing schema extension file" + install -d -m 0755 "/usr/share/glib-2.0/schemas/" + install -D -p -m 0644 "${TMP_DIR}/schemas/${SCHEMA_ID}.gschema.xml" "/usr/share/glib-2.0/schemas/${SCHEMA_ID}.gschema.xml" + # Install languages + echo "Installing language extension files" + install -d -m 0755 "/usr/share/locale/" + cp -r "${TMP_DIR}/locale"/* "/usr/share/locale/" + # Delete the temporary directory + echo "Cleaning up the temporary directory" + rm -r "${TMP_DIR}" + echo "------------------------------DONE----------------------------------" + done +else + echo "ERROR: You did not specify gettext-domain" + exit 1 +fi + +echo "Finished the installation of Gnome extensions" diff --git a/modules/gnome-extensions/module.yml b/modules/gnome-extensions/module.yml new file mode 100644 index 0000000..946fd94 --- /dev/null +++ b/modules/gnome-extensions/module.yml @@ -0,0 +1,8 @@ +name: gnome-extensions +shortdesc: The gnome-extensions module can be used to install Gnome extensions inside system directory. +readme: https://raw.githubusercontent.com/blue-build/modules/main/modules/gnome-extensions/README.md +example: | + type: gnome-extensions + install: + gettext-domain: # Omit @ symbol from gettext-domain. You can see the gettext-domain by looking into extension metadata.json. + - nightthemeswitcherromainvigier.fr.v75 # Version must be specified by adding .v%VERSION% after gettext domain. Extension version must be compatible with current Gnome version.