From f9c36b2f3b5e061a55439441216a24944bfc2297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Tue, 6 Oct 2026 21:15:32 -0400 Subject: [PATCH] Offer to log out after a region switch, in the new region's language --- bin/omarchy-region | 14 +++++++++++++- manual/52-china.md | 2 +- test/shell.d/region-switch-test.sh | 16 +++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/bin/omarchy-region b/bin/omarchy-region index 060297f9..3321e735 100755 --- a/bin/omarchy-region +++ b/bin/omarchy-region @@ -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 diff --git a/manual/52-china.md b/manual/52-china.md index 288b786f..cb33bde2 100644 --- a/manual/52-china.md +++ b/manual/52-china.md @@ -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. diff --git a/test/shell.d/region-switch-test.sh b/test/shell.d/region-switch-test.sh index fe65ee06..e688af88 100755 --- a/test/shell.d/region-switch-test.sh +++ b/test/shell.d/region-switch-test.sh @@ -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"