From 4118392c64e8aa69d43d101962839731609bf848 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Thu, 26 Mar 2026 11:10:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(locale):=20=E6=8F=90=E5=8F=96=20locale?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=E4=B8=BA=20decman=20Module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locale_module.py | 16 ++++++++++++++++ scripts/install.sh | 3 --- source.py | 15 ++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 locale_module.py diff --git a/locale_module.py b/locale_module.py new file mode 100644 index 0000000..0bc56be --- /dev/null +++ b/locale_module.py @@ -0,0 +1,16 @@ +import decman +from decman import File, Module + + +class LocaleModule(Module): + def __init__(self): + super().__init__("locale") + + def files(self): + return { + "/etc/locale.conf": File(content="LANG=en_US.UTF-8\n"), + "/etc/locale.gen": File(content="en_US.UTF-8 UTF-8\n"), + } + + def on_change(self, store): + decman.prg(["locale-gen"]) diff --git a/scripts/install.sh b/scripts/install.sh index 6ec814a..911cfc9 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -37,9 +37,6 @@ yay -S --needed --noconfirm decman echo "==> 应用系统配置..." sudo decman --source "$CONFIG_DIR/source.py" -echo "==> 生成 locale..." -sudo locale-gen - echo "==> 设置默认 shell 为 zsh..." if [ "$SHELL" != "$(which zsh)" ]; then sudo chsh -s "$(which zsh)" "$USER" diff --git a/source.py b/source.py index 7aac7d1..2be2bed 100644 --- a/source.py +++ b/source.py @@ -11,6 +11,8 @@ import os import decman from decman import File +import locale_module + assert decman.pacman is not None assert decman.aur is not None @@ -43,14 +45,12 @@ decman.pacman.packages |= { # ── AUR 包 ──────────────────────────────────────────────────── decman.aur.packages |= { - "decman", - "yay", - # 开发工具 "bun", - "mise", - # Zsh 插件 + "decman", "fzf-tab-git", + "mise", "oh-my-zsh-git", + "yay", } # ── 系统文件(/etc/)────────────────────────────────────────── @@ -63,10 +63,7 @@ decman.files["/etc/sudoers.d/10-wheel"] = File( permissions=0o440, ) -decman.files["/etc/locale.conf"] = File(content="LANG=en_US.UTF-8\n") - -# 仅保留需要的 locale;修改后需手动执行 locale-gen -decman.files["/etc/locale.gen"] = File(content="en_US.UTF-8 UTF-8\n") +decman.modules += [locale_module.LocaleModule()] # ── 用户配置 ───────────────────────────────────────────────── decman.files[f"{HOME}/.zshrc"] = File(