Offer to log out after a region switch, in the new region's language

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 21:15:32 -04:00
1 parent a77c246d38
commit f9c36b2f3b
3 files changed
+29 -3

No files matched your search

+15 -1
View File
@@ -14,11 +14,12 @@ rewrite() { sed -e "s|/etc/|$root/etc/|g" -e "s| /\\.cargo/| $root/.cargo/|g" "$
rewrite "$ROOT/install/config/region.sh" "$sandbox/install/config/region.sh"
rewrite "$ROOT/bin/omarchy-region" "$sandbox/bin/omarchy-region"
for command in omarchy-update-pacman omarchy-pkg-add locale-gen rime-ice-installer omarchy-setup-claude-api systemctl; do
for command in omarchy-update-pacman omarchy-pkg-add locale-gen rime-ice-installer omarchy-setup-claude-api systemctl omarchy-system-logout; do
printf '#!/bin/bash\necho "%s $*" >>"%s"\n' "$command" "$calls" >"$test_tmp/bin/$command"
done
printf '#!/bin/bash\necho "omarchy-pkg-add $*" >>"%s"\n[[ -z ${STUB_PKG_FAIL:-} ]]\n' "$calls" >"$test_tmp/bin/omarchy-pkg-add"
printf '#!/bin/bash\n[[ $1 == env ]] && shift\nexec env "$@"\n' >"$test_tmp/bin/sudo"
printf '#!/bin/bash\necho "gum $*" >>"%s"\nexit "${GUM_ANSWER:-1}"\n' "$calls" >"$test_tmp/bin/gum"
chmod +x "$test_tmp/bin"/*
export PATH="$test_tmp/bin:$sandbox/bin:$PATH" OMARCHY_PATH="$sandbox" HOME="$test_tmp/home"
@@ -75,6 +76,19 @@ fi
fail "a failed switch to China leaves the region and the mirrors Global"
pass "a failed switch to China leaves the machine Global"
grep -q '^gum' "$calls" && fail "a switch without a terminal asks nothing" "$(<"$calls")"
: >"$calls"
output=$(GUM_ANSWER=1 script -qec "omarchy-region china" /dev/null)
grep -qxF 'gum confirm --affirmative 立即注销 --negative 稍后 立即注销,切换到中文界面和国内镜像?' "$calls" ||
fail "switching to China offers to log out, in Chinese" "$(<"$calls")"
[[ $output == *"区域已设为中国。重新登录后切换到中文界面和国内镜像。"* ]] && ! grep -q '^omarchy-system-logout' "$calls" ||
fail "declining the logout leaves a reminder and the session" "$output"
: >"$calls"
GUM_ANSWER=0 script -qec "omarchy-region global" /dev/null >/dev/null
grep -qxF 'gum confirm --affirmative Log out now --negative Later Log out now to switch to English and the global mirrors?' "$calls" &&
grep -qx 'omarchy-system-logout ' "$calls" || fail "switching to Global offers to log out in English and logs out on yes" "$(<"$calls")"
pass "a switch in a terminal offers to log out in the new region's language"
rc_migration="$test_tmp/1788112314.sh"
rewrite "$ROOT/migrations/1788112314.sh" "$rc_migration"
cp "$ROOT/default/pacman/mirrorlist-rc" "$root/etc/pacman.d/mirrorlist"