Created
April 14, 2026 20:20
-
-
Save nunq/a3fe7b71ad27be2fbe0b1851f98cb1e1 to your computer and use it in GitHub Desktop.
ALPM hook script to check if your gnome extensions are compatible with the next gnome shell release
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # check if your enabled GNOME Shell extensions support the next GNOME version. | |
| # depends: curl, jq | |
| set -euo pipefail | |
| API="https://extensions.gnome.org/extension-info/?uuid=" | |
| RED=$'\033[0;31m' | |
| GREEN=$'\033[0;32m' | |
| YELLOW=$'\033[0;33m' | |
| RESET=$'\033[0m' | |
| UPDATE_DATA=$(pacman -Qu gnome-shell 2>/dev/null) || true | |
| if [[ -z "$UPDATE_DATA" ]]; then | |
| echo "Couldn't find any updates for gnome-shell." | |
| exit 0 | |
| fi | |
| # "gnome-shell 1:49.5-1 -> 1:50.0-1" — strip epoch (N:) from both sides | |
| GNOME_VERSION=$(echo "$UPDATE_DATA" | grep -oP '\d+(?=\.\d+-\d+ ->)') | |
| GNOME_VERSION_NEXT=$(echo "$UPDATE_DATA" | grep -oP '(?<=-> )[\d:]+' | sed 's/^[0-9]*://' | grep -oP '^\d+') | |
| if [[ "$GNOME_VERSION_NEXT" -le "$GNOME_VERSION" ]]; then | |
| echo "No major version change ($GNOME_VERSION -> $GNOME_VERSION_NEXT), nothing to check." | |
| exit 0 | |
| fi | |
| # get extension uuids | |
| mapfile -t UUIDS < <(/usr/bin/gnome-extensions list --enabled) | |
| if [[ ${#UUIDS[@]} -eq 0 ]]; then | |
| echo "No enabled extensions found." >&2 | |
| exit 1 | |
| fi | |
| echo -e "\nGNOME $GNOME_VERSION --> $GNOME_VERSION_NEXT extension compatibility check" | |
| COMPATIBLE=0 | |
| INCOMPATIBLE=0 | |
| UNKNOWN=0 | |
| check_extension() { | |
| local uuid="$1" | |
| local encoded | |
| # url encode the uuid | |
| encoded=$(jq --raw-input --raw-output @uri <<< "$uuid") | |
| local url="${API}${encoded}" | |
| local http_code body | |
| body=$(curl --fail --silent --show-error --max-time 10 --write-out "\n%{http_code}" "$url" 2>/dev/null) || true | |
| # read http code from last line | |
| http_code=$(tail -1 <<< "$body") | |
| body=$(sed '$d' <<< "$body") | |
| if [[ "$http_code" == "404" || -z "$body" ]]; then | |
| echo "[${YELLOW}??${RESET}] $uuid (not found)" | |
| ((UNKNOWN++)) || true | |
| return | |
| fi | |
| local name has_version | |
| name=$(jq --raw-output '.name // ""' <<< "$body" 2>/dev/null || echo "") | |
| has_version=$(jq --raw-output --arg v "$GNOME_VERSION_NEXT" 'if .shell_version_map[$v] then "yes" else "no" end' <<< "$body" 2>/dev/null || echo "no") | |
| local display="$uuid" | |
| [[ -n "$name" ]] && display="$name ($uuid)" | |
| if [[ "$has_version" == "yes" ]]; then | |
| echo "[${GREEN}OK${RESET}] $display" | |
| ((COMPATIBLE++)) || true | |
| else | |
| local latest_shell | |
| latest_shell=$(jq --raw-output '.shell_version_map | keys | map(select(test("^[0-9]+$"))) | map(tonumber) | max // "?" | tostring' <<< "$body" 2>/dev/null || echo "?") | |
| echo "[${RED}NO${RESET}] $display (latest: v$latest_shell)" | |
| ((INCOMPATIBLE++)) || true | |
| fi | |
| } | |
| for uuid in "${UUIDS[@]}"; do | |
| [[ -z "$uuid" ]] && continue | |
| check_extension "$uuid" | |
| # dont be too quick | |
| sleep 0.15 | |
| done | |
| echo -e "\nFor GNOME $GNOME_VERSION_NEXT: $COMPATIBLE compatible, $INCOMPATIBLE incompatible, $UNKNOWN unknown" | |
| if [[ $INCOMPATIBLE -gt 0 ]]; then | |
| echo -e "\n${RED}Some extensions are not compatible with the next GNOME version. Please update your IgnorePkg.${RESET}\n" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment