From afa43622a2b0d6322f5ade9fc8231e5540a96736 Mon Sep 17 00:00:00 2001 From: shu Date: Sun, 25 Oct 2026 23:46:15 +0800 Subject: 使用 stow + 脚本的形式维护系统基础 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 17 +++ dotfiles/agents/Agents.md | 4 + dotfiles/bash/.bash_logout | 3 + dotfiles/bash/.bash_profile | 5 + dotfiles/bash/.bashrc | 26 ++++ dotfiles/fcitx/.config/fcitx5/conf/classicui.conf | 34 +++++ dotfiles/fcitx/.config/fcitx5/conf/pinyin.conf | 155 +++++++++++++++++++++ dotfiles/git/.gitconfig | 16 +++ dotfiles/go/.config/go/env | 2 + dotfiles/kde/.config/environment.d/electron.conf | 1 + dotfiles/npm/.npmrc | 3 + dotfiles/uv/.config/uv/uv.toml | 4 + .../.config/Code - OSS/User/keybindings.json | 3 + .../vscode/.config/Code - OSS/User/settings.json | 18 +++ scripts/install_packages.sh | 8 ++ scripts/install_vscode_extensions.sh | 17 +++ scripts/pnpm.sh | 10 ++ scripts/stow.sh | 8 ++ scripts/system.sh | 122 ++++++++++++++++ 19 files changed, 456 insertions(+) create mode 100644 README.md create mode 100644 dotfiles/agents/Agents.md create mode 100644 dotfiles/bash/.bash_logout create mode 100644 dotfiles/bash/.bash_profile create mode 100644 dotfiles/bash/.bashrc create mode 100644 dotfiles/fcitx/.config/fcitx5/conf/classicui.conf create mode 100644 dotfiles/fcitx/.config/fcitx5/conf/pinyin.conf create mode 100644 dotfiles/git/.gitconfig create mode 100644 dotfiles/go/.config/go/env create mode 100644 dotfiles/kde/.config/environment.d/electron.conf create mode 100644 dotfiles/npm/.npmrc create mode 100644 dotfiles/uv/.config/uv/uv.toml create mode 100644 dotfiles/vscode/.config/Code - OSS/User/keybindings.json create mode 100644 dotfiles/vscode/.config/Code - OSS/User/settings.json create mode 100755 scripts/install_packages.sh create mode 100755 scripts/install_vscode_extensions.sh create mode 100755 scripts/pnpm.sh create mode 100755 scripts/stow.sh create mode 100644 scripts/system.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..201f4aa --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# infra archlinux + +## 需求 + +- 使用 stow 备份用户目录配置 (scripts/stow.sh) +- 使用 shell 脚本维护以下内容 + - 软件包的安装 (scripts/install_packages.sh) + - Node.js 开发环境 (scripts/pnpm.sh) + - code oss 插件安装 (scripts/install_vscode_extensions.sh) + - 系统服务配置备份和恢复 (scripts/system.sh) + +## todo + +- mpv 配置 +- aur +- 指纹识别 +- 加密信息处理 (scripts/system.sh) \ No newline at end of file diff --git a/dotfiles/agents/Agents.md b/dotfiles/agents/Agents.md new file mode 100644 index 0000000..524f3fb --- /dev/null +++ b/dotfiles/agents/Agents.md @@ -0,0 +1,4 @@ +# 全局 AI 要求 + +- 提交代码时必须使用详细的中文描述:commit message 使用中文,并说明变更内容、原因和验证方式。 +- AI 在交互过程中的对话输出内容尽量使用中文。 diff --git a/dotfiles/bash/.bash_logout b/dotfiles/bash/.bash_logout new file mode 100644 index 0000000..0e4e4f1 --- /dev/null +++ b/dotfiles/bash/.bash_logout @@ -0,0 +1,3 @@ +# +# ~/.bash_logout +# diff --git a/dotfiles/bash/.bash_profile b/dotfiles/bash/.bash_profile new file mode 100644 index 0000000..5545f00 --- /dev/null +++ b/dotfiles/bash/.bash_profile @@ -0,0 +1,5 @@ +# +# ~/.bash_profile +# + +[[ -f ~/.bashrc ]] && . ~/.bashrc diff --git a/dotfiles/bash/.bashrc b/dotfiles/bash/.bashrc new file mode 100644 index 0000000..0826f83 --- /dev/null +++ b/dotfiles/bash/.bashrc @@ -0,0 +1,26 @@ +# +# ~/.bashrc +# + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +alias ls='ls --color=auto' +alias grep='grep --color=auto' +PS1='[\u@\h \W]\$ ' + +export PATH=$HOME/.local/npm/bin:$HOME/.local/share/pnpm/bin:$PATH + +export FNM_NODE_DIST_MIRROR=https://mirrors.nju.edu.cn/nodejs-release/ +export RUSTUP_UPDATE_ROOT=https://mirror.nju.edu.cn/rustup/rustup +export RUSTUP_DIST_SERVER=https://mirror.nju.edu.cn/rustup + +eval "$(fnm env --use-on-cd)" + +# # pnpm +# export PNPM_HOME='/home/shu/.local/share/pnpm' +# case ":$PATH:" in +# ":$PNPM_HOME/bin:"*) ;; +# *) export PATH="$PNPM_HOME/bin:$PATH" ;; +# esac +# # pnpm end diff --git a/dotfiles/fcitx/.config/fcitx5/conf/classicui.conf b/dotfiles/fcitx/.config/fcitx5/conf/classicui.conf new file mode 100644 index 0000000..77934db --- /dev/null +++ b/dotfiles/fcitx/.config/fcitx5/conf/classicui.conf @@ -0,0 +1,34 @@ +# 垂直候选列表 +Vertical Candidate List=True +# 使用鼠标滚轮翻页 +WheelForPaging=True +# 字体 +Font="Sans 10" +# 菜单字体 +MenuFont="Sans 10" +# 托盘字体 +TrayFont="Sans Bold 10" +# 托盘标签轮廓颜色 +TrayOutlineColor=#000000 +# 托盘标签文本颜色 +TrayTextColor=#ffffff +# 优先使用文字图标 +PreferTextIcon=False +# 在图标中显示布局名称 +ShowLayoutNameInIcon=True +# 使用输入法的语言来显示文字 +UseInputMethodLanguageToDisplayText=True +# 主题 +Theme=plasma +# 深色主题 +DarkTheme=plasma +# 跟随系统浅色/深色设置 +UseDarkTheme=False +# 当被主题和桌面支持时使用系统的重点色 +UseAccentColor=True +# 在 X11 上针对不同屏幕使用单独的 DPI +PerScreenDPI=False +# 固定 Wayland 的字体 DPI +ForceWaylandDPI=0 +# 在 Wayland 下启用分数缩放 +EnableFractionalScale=True diff --git a/dotfiles/fcitx/.config/fcitx5/conf/pinyin.conf b/dotfiles/fcitx/.config/fcitx5/conf/pinyin.conf new file mode 100644 index 0000000..83afecc --- /dev/null +++ b/dotfiles/fcitx/.config/fcitx5/conf/pinyin.conf @@ -0,0 +1,155 @@ +# 双拼方案 +# ShuangpinProfile=Ziranma +# 显示当前双拼模式 +# ShowShuangpinMode=True +# 每页候选词 +# PageSize=7 +# 显示英文候选词 +# SpellEnabled=True +# 显示符号候选词 +# SymbolsEnabled=True +# 显示拆字候选词 +# ChaiziEnabled=True +# 启用 Unicode CJK 拓展区 B 之后的更多字符 +# ExtBEnabled=True +# 输入 h(横),s(竖),p(撇),n(捺),z(折) 时显示笔画候选词 +# StrokeCandidateEnabled=True +# 启用云拼音 +# CloudPinyinEnabled=False +# 云拼音候选词顺序 +# CloudPinyinIndex=2 +# 加载云拼音的时候显示动画 +# CloudPinyinAnimation=True +# 总是显示云拼音的占位符 +# KeepCloudPinyinPlaceHolder=False +# 预编辑模式 +# PreeditMode="Composing pinyin" +# 将嵌入预编辑文本的光标固定在开头 +# PreeditCursorPositionAtBeginning=True +# 在预编辑中显示完整拼音 +# PinyinInPreedit=False +# 启用预测 +# Prediction=False +# 为下次输入预测保留当前输入的文本 +# KeepCurrentContext=True +# 预测数量 +# PredictionSize=49 +# 预测时退格键的行为 +# BackspaceBehaviorOnPrediction="Backspace when not using on-screen keyboard" +# 切换输入法时的行为 +# SwitchInputMethodBehavior="Commit current preedit" +# 学习 +# Learning=True +# 选择第二个候选词 +# SecondCandidate= +# 选择第三个候选词 +# ThirdCandidate= +# 使用数字键盘选词 +# UseKeypadAsSelection=False +# 选词末字 +# ChooseLastCharFromPhrase=bracketright +# 使用退格键取消选词 +# BackSpaceToUnselect=True +# 句子数量 +# Number of sentence=2 +# 词组候选词数 +# WordCandidateLimit=15 +# 输入长于...时提示长词 (设置为 0 时禁用) +# LongWordLengthLimit=4 +# 快速输入的触发键 +QuickPhraseKey= +# 使用 V 来触发快速输入 +# VAsQuickphrase=True +# FirstRun +FirstRun=False + +# [ForgetWord] +# 0=Control+7 + +# [PrevPage] +# 0=minus +# 1=Up +# 2=KP_Up +# 3=Page_Up + +# [NextPage] +# 0=equal +# 1=Down +# 2=KP_Down +# 3=Next + +# [PrevCandidate] +# 0=Shift+Tab + +# [NextCandidate] +# 0=Tab + +# [CurrentCandidate] +# 0=space +# 1=KP_Space + +# [CommitRawInput] +# 0=Return +# 1=KP_Enter +# 2=Control+Return +# 3=Control+KP_Enter +# 4=Shift+Return +# 5=Shift+KP_Enter +# 6=Control+Shift+Return +# 7=Control+Shift+KP_Enter + +# [ChooseCharFromPhrase] +# 0=bracketleft + +# [FilterByStroke] +# 0=grave + +# [QuickPhraseTriggerRegex] +# 0=.(/|@)$ +# 1="^(www|bbs|forum|mail)\\." +# 2=^(http|https|ftp|telnet|mailto): + +# [Fuzzy] +# ue -> ve +# VE_UE=True +# 常见错误 +# NG_GN=True +# 小写时匹配字母 +# LowerCaseMatchLetter=True +# 内模糊音节 (xian -> xi'an) +# Inner=True +# 短拼音的内模糊音节 (qie -> qi'e) +# InnerShort=True +# 匹配不完整的元音 (e -> en, eng, ei) +# PartialFinal=False +# 输入长度大于 4 时进行部分双拼匹配 +# PartialSp=False +# u <-> v +# V_U=False +# an <-> ang +# AN_ANG=False +# en <-> eng +# EN_ENG=False +# ian <-> iang +# IAN_IANG=False +# in <-> ing +# IN_ING=False +# u <-> ou +# U_OU=False +# uan <-> uang +# UAN_UANG=False +# c <-> ch +# C_CH=False +# f <-> h +# F_H=False +# l <-> n +# L_N=False +# l <-> r +# L_R=False +# s <-> sh +# S_SH=False +# z <-> zh +# Z_ZH=False +# 纠错布局 +# Correction=None + diff --git a/dotfiles/git/.gitconfig b/dotfiles/git/.gitconfig new file mode 100644 index 0000000..a675a80 --- /dev/null +++ b/dotfiles/git/.gitconfig @@ -0,0 +1,16 @@ +[init] + defaultBranch = main +[user] + email = nvcsadjkojf@outlook.com + name = shu +[core] + pager = delta +[interactive] + diffFilter = delta --color-only +[delta] + navigate = true + dark = true +[merge] + conflictStyle = zdiff3 +[alias] + l = log --oneline diff --git a/dotfiles/go/.config/go/env b/dotfiles/go/.config/go/env new file mode 100644 index 0000000..fc844eb --- /dev/null +++ b/dotfiles/go/.config/go/env @@ -0,0 +1,2 @@ +GOPROXY=https://goproxy.cn,direct +GOSUMDB=sum.golang.google.cn \ No newline at end of file diff --git a/dotfiles/kde/.config/environment.d/electron.conf b/dotfiles/kde/.config/environment.d/electron.conf new file mode 100644 index 0000000..4cc8650 --- /dev/null +++ b/dotfiles/kde/.config/environment.d/electron.conf @@ -0,0 +1 @@ +ELECTRON_FORCE_WINDOW_MENU_BAR=1 diff --git a/dotfiles/npm/.npmrc b/dotfiles/npm/.npmrc new file mode 100644 index 0000000..4b97c69 --- /dev/null +++ b/dotfiles/npm/.npmrc @@ -0,0 +1,3 @@ +loglevel=http +registry=https://registry.npmmirror.com/ +prefix=/home/shu/.local/npm \ No newline at end of file diff --git a/dotfiles/uv/.config/uv/uv.toml b/dotfiles/uv/.config/uv/uv.toml new file mode 100644 index 0000000..6a077ac --- /dev/null +++ b/dotfiles/uv/.config/uv/uv.toml @@ -0,0 +1,4 @@ +[[index]] +name = "nju" +url = "https://mirror.nju.edu.cn/pypi/web/simple" +default = true diff --git a/dotfiles/vscode/.config/Code - OSS/User/keybindings.json b/dotfiles/vscode/.config/Code - OSS/User/keybindings.json new file mode 100644 index 0000000..9e824cf --- /dev/null +++ b/dotfiles/vscode/.config/Code - OSS/User/keybindings.json @@ -0,0 +1,3 @@ +// Place your key bindings in this file to override the defaults +[ +] \ No newline at end of file diff --git a/dotfiles/vscode/.config/Code - OSS/User/settings.json b/dotfiles/vscode/.config/Code - OSS/User/settings.json new file mode 100644 index 0000000..e883c81 --- /dev/null +++ b/dotfiles/vscode/.config/Code - OSS/User/settings.json @@ -0,0 +1,18 @@ +{ + "window.menuStyle": "native", + "window.dialogStyle": "native", + "window.titleBarStyle": "native", + "window.controlsStyle": "native", + "window.title": "${rootName}${separator}${dirty}${activeEditorShort}${separator}${appName}", + + "chat.disableAIFeatures": true, + + "editor.fontSize": 14, + "editor.tabSize": 2, + "editor.renderWhitespace": "boundary", + "editor.wordWrap": "off", + "editor.rulers": [80, 120], + "editor.renderControlCharacters": true, + "editor.fontLigatures": true, + "workbench.iconTheme": "vscode-icons", +} \ No newline at end of file diff --git a/scripts/install_packages.sh b/scripts/install_packages.sh new file mode 100755 index 0000000..2c648b3 --- /dev/null +++ b/scripts/install_packages.sh @@ -0,0 +1,8 @@ +#/bin/bash + +PKG_BASE="kde-applications-meta chromium code shadowsocks-rust dae base-devel git git-delta vim uv fnm stow bind lsof eza bat bat-extras htop jq less unzip 7zip wget" +PKG_HARDWARE="usb_modeswitch solaar brightnessctl terminus-font" +PKG_DEV="go rustup plantuml caddy docker docker-buildx docker-compose" +PKG_DESKTOP="bitwarden telegram-desktop darktable digikam obs-studio fcitx5 fcitx5-chinese-addons fcitx5-configtool fcitx5-pinyin-zhwiki" + +sudo pacman -Syu --needed $PKG_BASE $PKG_HARDWARE $PKG_DEV $PKG_DESKTOP \ No newline at end of file diff --git a/scripts/install_vscode_extensions.sh b/scripts/install_vscode_extensions.sh new file mode 100755 index 0000000..9aa1e15 --- /dev/null +++ b/scripts/install_vscode_extensions.sh @@ -0,0 +1,17 @@ +#/bin/bash + +EXTENSIONS=( + "yzhang.markdown-all-in-one" # https://open-vsx.org/extension/yzhang/markdown-all-in-one + "golang.Go" # https://open-vsx.org/extension/golang/Go + "EditorConfig.EditorConfig" # https://open-vsx.org/extension/EditorConfig/EditorConfig + "vscode-icons-team.vscode-icons" # https://open-vsx.org/extension/vscode-icons-team/vscode-icons + "Vue.volar" # https://open-vsx.org/extension/Vue/volar + "redhat.vscode-yaml" # https://open-vsx.org/extension/redhat/vscode-yaml + "tamasfe.even-better-toml" # https://open-vsx.org/extension/tamasfe/even-better-toml + "jebbs.plantuml" # https://open-vsx.org/extension/jebbs/plantuml + "rust-lang.rust-analyzer" # https://open-vsx.org/extension/rust-lang/rust-analyzer +) + +for ext in "${EXTENSIONS[@]}"; do + code --install-extension "$ext" +done diff --git a/scripts/pnpm.sh b/scripts/pnpm.sh new file mode 100755 index 0000000..90259db --- /dev/null +++ b/scripts/pnpm.sh @@ -0,0 +1,10 @@ +#/bin/bash + +CURRENT_VERSION=24 +export FNM_NODE_DIST_MIRROR=https://mirrors.nju.edu.cn/nodejs-release/ + +fnm install $CURRENT_VERSION +fnm use $CURRENT_VERSION +npm i -g pnpm +pnpm setup +pnpm i -g serve tiddlywiki @deepseek-ai/dsh \ No newline at end of file diff --git a/scripts/stow.sh b/scripts/stow.sh new file mode 100755 index 0000000..d4322e4 --- /dev/null +++ b/scripts/stow.sh @@ -0,0 +1,8 @@ +#/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +DOTFILE_DIR="$(cd $SCRIPT_DIR && cd ../dotfiles && pwd)" +echo $DOTFILE_DIR + +# add link +cd $DOTFILE_DIR && stow -d $DOTFILE_DIR -t $HOME --no-folding --adopt */ \ No newline at end of file diff --git a/scripts/system.sh b/scripts/system.sh new file mode 100644 index 0000000..31864b9 --- /dev/null +++ b/scripts/system.sh @@ -0,0 +1,122 @@ +#/bin/bash + +# 脏标记:0=不需要重建 UKI,1=需要 +MKINITCPIO=0 + +setup_vconsole_font() { + sudo sed -i 's/^\(FONT=.*\)$/# \1\nFONT=ter-132n/' /etc/vconsole.conf + + sudo cp /etc/kernel/cmdline /etc/kernel/cmdline.bak + sudo sed -i 's/$/ fbcon=font:TER16x32/' /etc/kernel/cmdline + + sudo cp /boot/loader/loader.conf /boot/loader/loader.conf.bak + sudo sed -i -e '/^[[:space:]]*#\?[[:space:]]*console-mode/d' /boot/loader/loader.conf + echo 'console-mode 1' | sudo tee -a /boot/loader/loader.conf >/dev/null + + # 标记需要重建 + MKINITCPIO=1 +} + +setup_shadowsocks() { + sudo cat > /etc/shadowsocks-rust/s.json < /etc/dae/config.dae < router + qname(suffix: lan) -> router + fallback: direct_dns + } + + response { + fallback: accept + } + } +} + +routing { + # Shadowsocks must reach its remote server directly to avoid a proxy loop. + pname(sslocal) -> direct + + # Keep local, multicast, and other private destinations direct. + dip(224.0.0.0/3, 'ff00::/8') -> direct + dip(geoip:private) -> direct + + # Route mainland China IPs directly. Everything else uses the proxy, so + # overseas destinations do not need to be maintained in a domain list. + dip(geoip:cn) -> direct + + fallback: proxy +} +EOF +} + +setup_vconsole_font +setup_shadowsocks +setup_dae + +# 统一重建一次 +if [ "$MKINITCPIO" -eq 1 ]; then + echo ">>> mkinitcpio -P" + sudo mkinitcpio -P +fi \ No newline at end of file -- cgit v1.2.3