Files
Panama/tests/quickshell/gnome-handoff-contract
T
Gabriel Brown dfc0c49877 Let the laptop say what it is doing: battery percentage, the lid, a fingerprint
Three surfaces the first laptop install showed were missing.

The bar's battery icon gets an optional exact number beside it -- GNOME's
"Show Battery Percentage", off by default for GNOME's reason, one color with
the icon so it reads as one indicator.

The Power page says what closing the lid does. The policy already existed
(LidPolicy holds a suspend inhibitor while an external display is connected)
but was surfaced nowhere, so the machine's most physical behavior was
undiscoverable -- and the deliberate absence of an override deserves stating
rather than leaving someone to hunt for a switch that does not exist.

And the Users page grows a Fingerprint card, because fingerprint login is two
systems that fail silently when they disagree: fprintd holds the enrolled
prints, authselect decides whether PAM ever asks the reader. This machine
arrived with a finger enrolled from its GNOME days and with-fingerprint off,
which reads as "the reader is broken". The card shows both facts, flips the
authselect feature through polkit with a stated reason, and hands enrollment
to GNOME's Users panel, which owns the only good capture dialog -- a named
exception in the handoff contract. Everything through scripts/panama-fingerprint,
pinned by a stub-driven contract.

Claude-Session: https://claude.ai/code/session_01Epx9ZC1gwm81K3jm9x9CKh
2026-08-23 11:07:37 -04:00

97 lines
3.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# No settings page may hand off to a GNOME panel that Panama itself owns.
#
# Panama absorbed Users, Sharing, Printers, Online Accounts and others one page
# at a time. Each time, the rows pointing at GNOME's equivalent stayed where
# they were -- so a settings app whose stated purpose is to make GNOME Settings
# unnecessary shipped four separate doors back to it, two of them inside a card
# headed "these areas remain owned by Fedora".
#
# Nothing failed. Every row worked exactly as written. The rows were simply no
# longer true, and no test could notice because none of them knew what Panama
# had come to own in the meantime.
#
# This reads the sidebar for the pages that exist and the pages for the panels
# they hand off, and fails on any overlap. It is deliberately derived from both
# sides rather than from a hand-kept list, so absorbing the next page cannot
# leave a stale door behind.
#
# Read-only.
set -uo pipefail
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
settings_dir="$repo_dir/config/dot/quickshell/modules/settings"
sidebar="$settings_dir/SettingsSidebar.qml"
fail() {
printf 'gnome handoff contract: %s\n' "$1" >&2
exit 1
}
[[ -r "$sidebar" ]] || fail "missing $sidebar"
# GNOME panel names that correspond to a Panama page. Only entries whose panel
# genuinely duplicates a Panama page belong here: "network" stays off it because
# Panama has no VPN or per-connection routing, and "online-accounts" is listed
# because Panama has an Online Accounts page -- but adding an account still has
# to go through GOA's own dialog, so that one exception is named explicitly.
declare -A OWNED=(
[printers]=printers
[online-accounts]=accounts
[sharing]=sharing
[users]=users
[system\ users]=users
)
# Handoffs that are correct despite naming an owned panel, with the reason.
# Anything here must be justified, not merely tolerated.
declare -A ALLOWED=(
["OnlineAccountsPage.qml:online-accounts"]="adding an account requires GOA's own dialog"
["UsersPage.qml:system-users"]="fingerprint enrollment requires fprintd's guided capture flow, and GNOME's Users panel carries the only good dialog for it"
)
pages="$(grep -oE '\{ *page: "[a-z-]+"' "$sidebar" | sed 's/.*"\(.*\)"/\1/' | sort -u)"
[[ -n "$pages" ]] || fail 'no pages could be read from the sidebar, so this proves nothing'
has_page() {
grep -qx "$1" <<<"$pages"
}
violations=0
checked=0
while IFS= read -r hit; do
file="${hit%%:*}"
base="$(basename "$file")"
# openGnomePanel("a") or openGnomePanel("a", "b") -> "a" / "a b"
panel="$(sed -E 's/.*openGnomePanel\("([^"]+)"(, *"([^"]+)")?\).*/\1 \3/' <<<"$hit" \
| sed 's/ *$//')"
[[ -n "$panel" ]] || continue
checked=$((checked + 1))
owner="${OWNED[$panel]:-}"
[[ -n "$owner" ]] || continue
has_page "$owner" || continue
key="$base:${panel// /-}"
if [[ -n "${ALLOWED[$key]:-}" ]]; then
continue
fi
printf 'gnome handoff contract: %s hands "%s" to GNOME, but Panama owns the "%s" page\n' \
"$base" "$panel" "$owner" >&2
violations=$((violations + 1))
done < <(grep -rno --include='*.qml' -E 'openGnomePanel\("[^"]*"(, *"[^"]*")?\)' "$settings_dir")
(( checked > 0 )) || fail 'no handoffs were examined, so this proves nothing'
if (( violations > 0 )); then
printf 'Each of these sends someone to GNOME for a page this app already has.\n' >&2
exit 1
fi
printf 'gnome handoff contract: ok (%d handoffs checked against %d pages)\n' \
"$checked" "$(wc -l <<<"$pages")"