Last active
February 18, 2026 12:20
-
-
Save zwzheng45/55edc1063d1c5f40c5569888ecbeb6bd to your computer and use it in GitHub Desktop.
定时同步rime词典
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| REPO_DIR="/Users/zzw/GitHub/rime-fast-xhup" | |
| TARGET_DIR="/Users/zzw/Library/Rime" | |
| cd "$REPO_DIR" || { echo "目录不存在"; exit 1; } | |
| pull_output="$(git pull 2>&1)" || { echo "$pull_output"; exit 1; } | |
| dry_cn="$(rsync -ani cn_dicts/ "$TARGET_DIR/cn_dicts/" 2>&1)" || { echo "$dry_cn"; exit 1; } | |
| dry_en="$(rsync -ani en_dicts/ "$TARGET_DIR/en_dicts/" 2>&1)" || { echo "$dry_en"; exit 1; } | |
| if [[ -z "$dry_cn" && -z "$dry_en" ]]; then | |
| exit 0 | |
| fi | |
| echo "从远程仓库更新... " | |
| echo "$pull_output" | |
| echo "覆盖旧词典... " | |
| # 同步中文词典文件 | |
| rsync -av cn_dicts/ "$TARGET_DIR/cn_dicts/" || { echo "覆盖失败"; exit 1; } | |
| # 同步英文词典文件 | |
| rsync -av en_dicts/ "$TARGET_DIR/en_dicts/" || { echo "覆盖失败"; exit 1; } | |
| osascript -e 'display notification "记得在空闲时重新部署" with title "Rime 词典已更新"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>com.zzw.auto_update_rime</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/bin/bash</string> | |
| <string>/Users/zzw/Library/LaunchAgents/auto_update_rime.sh</string> | |
| </array> | |
| <key>RunAtLoad</key> | |
| <true/> | |
| <key>StartInterval</key> | |
| <integer>1800</integer> | |
| <key>StandardOutPath</key> | |
| <string>/tmp/auto_update_rime.out</string> | |
| <key>StandardErrorPath</key> | |
| <string>/tmp/auto_update_rime.err</string> | |
| </dict> | |
| </plist> |
Author
Author
改成了启动时自动运行+每30分钟检查一次。
launchctl加载的新语法是launchctl bootstrap gui/$(id -u) com.zzw.auto_update_rime.plist
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
launchctl load com.zzw.auto_update_rime.plist