Files
omarchy/install/config/region.sh
T
ZacharyZhang-NY 9a57690e7d Align the China region to the official cn profile
The region value is cn, the China files live under default/regions/cn/, and
omarchy-apply-pacman renders pacman for every caller: the .cn twins of the
channel servers first, then .org, USTC and ArchLinuxCN. Switching to China
installs and trusts the ArchLinuxCN keyring. A migration renames china to cn
and repoints the drop-in links.
2026-10-07 11:33:01 -04:00

48 lines
1.3 KiB
Bash

cn_links=(
"environment.conf /etc/environment.d/90-omarchy-china.conf"
"cargo.toml /.cargo/config.toml"
"gemrc /etc/gemrc"
)
case ${OMARCHY_REGION:-global} in
global)
rm -f /etc/omarchy/region
sed -i 's/^LANG=zh_CN\.UTF-8$/LANG=en_US.UTF-8/' /etc/locale.conf
for link in "${cn_links[@]}"; do
read -r _ target <<<"$link"
if [[ -L $target && $(readlink "$target") == */default/regions/cn/* ]]; then
rm "$target"
fi
done
;;
cn)
# Packages first, so a failed install leaves the machine Global.
omarchy-pkg-add fcitx5-configtool fcitx5-rime librime opencc rime-ice-installer
for link in "${cn_links[@]}"; do
read -r _ target <<<"$link"
if [[ -e $target && ! -L $target ]]; then
echo "Refusing to replace $target, which Omarchy did not create" >&2
exit 1
fi
done
mkdir -p /etc/omarchy
echo cn >/etc/omarchy/region
for link in "${cn_links[@]}"; do
read -r source target <<<"$link"
mkdir -p "${target%/*}"
ln -sfn "$OMARCHY_PATH/default/regions/cn/$source" "$target"
done
sed -i 's/^#\(zh_CN\.UTF-8 UTF-8\)/\1/' /etc/locale.gen
locale-gen
if grep -q '^LANG=' /etc/locale.conf; then
sed -i 's/^LANG=.*/LANG=zh_CN.UTF-8/' /etc/locale.conf
else
echo LANG=zh_CN.UTF-8 >>/etc/locale.conf
fi
;;
*)
echo "Unknown OMARCHY_REGION: $OMARCHY_REGION" >&2
exit 1
;;
esac