Switch regions from Setup > Region and show Chinese menu labels under zh_CN
This commit is contained in:
1 parent
56c8344fd2
commit
5f6c803b21
12 files changed
+408
-18
No files matched your search
+42
-7
@@ -1,16 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Show the region this machine is set up for
|
||||
# omarchy:summary=Show or switch the region this machine is set up for
|
||||
# omarchy:args=[global|china]
|
||||
# omarchy:examples=omarchy region | omarchy region china
|
||||
# omarchy:requires-sudo=true
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
region_file=/etc/omarchy/region
|
||||
|
||||
if [[ ! -e $region_file ]]; then
|
||||
echo "Global"
|
||||
elif [[ $(<"$region_file") == "china" ]]; then
|
||||
echo "China"
|
||||
else
|
||||
echo "Unknown region in $region_file: $(<"$region_file")" >&2
|
||||
if (($# == 0)); then
|
||||
if [[ ! -e $region_file ]]; then
|
||||
echo "Global"
|
||||
elif [[ $(<"$region_file") == "china" ]]; then
|
||||
echo "China"
|
||||
else
|
||||
echo "Unknown region in $region_file: $(<"$region_file")" >&2
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $1 != "global" && $1 != "china" ]]; then
|
||||
echo "Usage: omarchy-region [global|china]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pacman_files=(/etc/pacman.conf /etc/pacman.d/mirrorlist)
|
||||
|
||||
if [[ $1 == "china" ]]; then
|
||||
for file in "${pacman_files[@]}"; do
|
||||
if ! grep -q '^Server = https://[a-z-]*\.omarchy\.cn/' "$file"; then
|
||||
sudo sed -i -f "$OMARCHY_PATH/default/region/china/pacman.sed" "$file"
|
||||
fi
|
||||
done
|
||||
echo "Package mirrors -> .cn first, .org after"
|
||||
sudo pacman -Sy
|
||||
sudo env OMARCHY_REGION=china OMARCHY_PATH="$OMARCHY_PATH" bash -e "$OMARCHY_PATH/install/config/region.sh"
|
||||
if [[ ! -f $HOME/.local/share/fcitx5/rime/rime_ice.schema.yaml ]]; then
|
||||
rime-ice-installer --yes
|
||||
fi
|
||||
else
|
||||
sudo sed -i '/^Server = https:\/\/[a-z-]*\.omarchy\.cn\//d' "${pacman_files[@]}"
|
||||
echo "Package mirrors -> .org only"
|
||||
sudo pacman -Sy
|
||||
sudo env OMARCHY_REGION=global OMARCHY_PATH="$OMARCHY_PATH" bash -e "$OMARCHY_PATH/install/config/region.sh"
|
||||
omarchy-setup-claude-api --remove
|
||||
fi
|
||||
|
||||
echo "Region set to ${1^}. Log out and back in to switch the language and developer mirrors."
|
||||
Reference in new issue
Block a user