#!/usr/bin/env bash # SPDX-License-Identifier: MIT set -euo pipefail if (( $# != 3 )); then printf 'Usage: %s SCRIPT PATCH FIXTURE\n' "${0##*/}" >&2 exit 2 fi script=$1 patch_file=$2 fixture=$3 tmpdir=$(mktemp -d) trap 'rm -rf -- "$tmpdir"' EXIT root="$tmpdir/root" target_dir="$root/usr/share/plasma/shells/org.kde.plasma.desktop/contents/lockscreen" target="$target_dir/LockScreenUi.qml" mkdir -p "$target_dir" cp "$fixture" "$target" run_tool() { PLASMA_ALWAYS_SHOW_UNLOCK_ROOT="$root" \ PLASMA_ALWAYS_SHOW_UNLOCK_PATCH="$patch_file" \ bash "$script" "$@" } if run_tool status >/dev/null 2>&1; then printf 'Expected an unpatched fixture.\n' >&2 exit 1 fi run_tool apply >/dev/null run_tool status >/dev/null grep -q 'function onViewVisibleChanged()' "$target" grep -q 'running: parent.uiVisible' "$target" grep -q 'onTriggered: authenticator.startAuthenticating()' "$target" if grep -q 'seenPositionChange\|lockScreenRoot.uiVisible = false' "$target"; then printf 'The patched fixture still contains prompt-hiding logic.\n' >&2 exit 1 fi patched_checksum=$(sha256sum "$target") run_tool apply >/dev/null [[ $(sha256sum "$target") == "$patched_checksum" ]] run_tool revert >/dev/null cmp "$fixture" "$target" sed -i 's/property bool seenPositionChange: false/property bool unexpectedState: false/' "$target" unsupported_checksum=$(sha256sum "$target") if run_tool apply >/dev/null 2>&1; then printf 'Expected an unsupported modified fixture to be rejected.\n' >&2 exit 1 fi [[ $(sha256sum "$target") == "$unsupported_checksum" ]] printf 'plasma-always-show-unlock tests passed\n'