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

+13 -1
View File
@@ -47,4 +47,16 @@ else
omarchy-setup-claude-api --remove
fi
echo "Region set to ${1^}. Log out and back in to switch the language and developer mirrors."
# The language and the developer mirrors reach only a new session, so offer one in the new language.
if [[ $1 == "china" ]]; then
prompt="立即注销,切换到中文界面和国内镜像?" log_out="立即注销" later="稍后"
reminder="区域已设为中国。重新登录后切换到中文界面和国内镜像。"
else
prompt="Log out now to switch to English and the global mirrors?" log_out="Log out now" later="Later"
reminder="Region set to Global. Log back in to switch to English and the global mirrors."
fi
if [[ -t 0 && -t 1 ]] && gum confirm --affirmative "$log_out" --negative "$later" "$prompt"; then
omarchy-system-logout
else
echo "$reminder"
fi
+1 -1
View File
@@ -34,7 +34,7 @@ _Setup > Claude Code API_ points Claude Code at DeepSeek, Kimi Code, GLM, MiniMa
## Switching regions
_Setup > Region_ switches an installed machine either way, or run `omarchy region china` or `omarchy region global` from a terminal. Switching to China first runs a full system update, so the input method installs against current packages, and then downloads Rime Ice. Log out and back in afterwards so the language and developer mirrors follow.
_Setup > Region_ switches an installed machine either way, or run `omarchy region china` or `omarchy region global` from a terminal. Switching to China first runs a full system update, so the input method installs against current packages, then sets up China and downloads Rime Ice; the package mirrors move to `.cn` last, so a failed switch leaves the machine Global. The language and the developer mirrors follow at the next login, so the switch then offers to log out at once.
Switching to Global moves packages back to the `.org` servers, the language back to English, and removes the developer mirrors, China Apps and the Claude Code API setup. It keeps the input method and the CJK fonts, so you can still type and read Chinese. `omarchy update` never changes the region or the language; only these switches do.
+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"