Add a Linux version (IBus) for Bazzite / SteamOS desktop mode
linux/autozhuyin_ibus.py is an IBus engine on top of the shared Python core: preedit with the cursor and blue English segments, lookup table, Shift tap for English mode, candidate clicks. install.sh puts everything in the home folder (works on read-only systems) and an autostart entry registers the engine with ibus-daemon and selects it. Tested with a stand-in IBus module. Also fixes Windows: wants() did not claim the backtick, so backtick + punctuation never reached the engine under PIME. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
自動注音 AutoZhuyin(Linux 測試版,IBus)
|
||||
=========================================
|
||||
|
||||
用大千注音鍵盤直接打字,不用切換中英文,輸入法會自動判斷你打的是注音還是英文。
|
||||
|
||||
按鍵: ji3 hello world su3cl3 (最後按空白)
|
||||
輸出: 我hello world 你好
|
||||
|
||||
適用:Bazzite、SteamOS 桌面模式、Fedora 等有 IBus 的系統(KDE 或 GNOME)。
|
||||
只在桌面模式可用;Steam 遊戲模式不支援系統輸入法。
|
||||
|
||||
|
||||
安裝
|
||||
----
|
||||
1. 解壓縮,在終端機(Konsole)進到這個資料夾,執行:
|
||||
./install.sh
|
||||
不需要 sudo,檔案只會裝在你的家目錄(~/.local/share/autozhuyin)。
|
||||
|
||||
2. KDE(Bazzite / SteamOS 預設):
|
||||
系統設定 → 鍵盤 → 虛擬鍵盤,選「IBus Wayland」→ 套用,然後登出再登入。
|
||||
GNOME:IBus 是內建的,不用另外設定。
|
||||
|
||||
3. 之後每次登入都會自動切換到自動注音。
|
||||
|
||||
|
||||
使用方式
|
||||
--------
|
||||
空白 注音:一聲;音節打完時送出中文。英文:送出單字加空白
|
||||
Enter 送出目前組字
|
||||
Tab 判斷錯了?按 Tab 在中/英之間翻轉,輸入法會記住這次修正
|
||||
← → 在組字區移動游標;游標在中間時直接打注音會插入新字,
|
||||
Backspace 刪掉游標前的字
|
||||
↓ 開啟游標前那個字或詞的候選字,按數字鍵 1–9 選字
|
||||
Esc 取消組字
|
||||
單按 Shift 切換英文模式(按鍵直接送出),再單按一次回到中英自動判斷
|
||||
Shift+字母 打大寫字母(也會強制英文)
|
||||
` + 標點 強制全形標點,例如 `< 或 `, = , `. = 。 `/ = ? `; = ;
|
||||
|
||||
注音符號的順序打錯也沒關係,例如 ㄧㄒㄠˇ 會自動變成 ㄒㄧㄠˇ(小)。
|
||||
|
||||
|
||||
切換與移除
|
||||
----------
|
||||
暫時改回一般鍵盤: ibus engine xkb:us::eng
|
||||
切回自動注音: ibus engine autozhuyin
|
||||
移除: ./uninstall.sh
|
||||
|
||||
個人資料(學習紀錄、自訂詞)在 ~/.config/autozhuyin/:
|
||||
learned.json 按 Tab 修正的學習紀錄
|
||||
user-phrases.txt 自訂詞,一行一個,例如:ㄗˋ-ㄉㄨㄥˋ 自動 -1
|
||||
|
||||
|
||||
有問題時
|
||||
--------
|
||||
在終端機手動執行看看錯誤訊息:
|
||||
/usr/bin/python3 ~/.local/share/autozhuyin/autozhuyin_ibus.py --activate
|
||||
把畫面上的訊息回報給我。
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
# Installs AutoZhuyin (自動注音) for the current user as an IBus input method.
|
||||
# Nothing outside your home folder is touched, so it works on read-only systems
|
||||
# (Bazzite, SteamOS, Fedora Atomic). No sudo needed.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
DEST="${XDG_DATA_HOME:-$HOME/.local/share}/autozhuyin"
|
||||
AUTOSTART="${XDG_CONFIG_HOME:-$HOME/.config}/autostart"
|
||||
PY=/usr/bin/python3
|
||||
|
||||
echo "== 自動注音 AutoZhuyin 安裝 =="
|
||||
|
||||
# 1. IBus and its Python bindings must come with the system.
|
||||
if ! command -v ibus >/dev/null 2>&1; then
|
||||
echo "找不到 IBus(ibus 指令)。這個系統沒有內建 IBus,自動注音目前只支援 IBus。" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! "$PY" -c 'import gi; gi.require_version("IBus", "1.0"); from gi.repository import IBus' 2>/dev/null; then
|
||||
echo "系統的 Python 缺少 IBus 模組(python3-gobject / IBus-1.0 typelib)。" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Copy the program.
|
||||
pkill -f "autozhuyin/autozhuyin_ibus.py" 2>/dev/null || true
|
||||
rm -rf "$DEST"
|
||||
mkdir -p "$DEST"
|
||||
cp -R autozhuyin autozhuyin_ibus.py version.txt "$DEST/"
|
||||
[ -f icon.png ] && cp icon.png "$DEST/"
|
||||
[ -f THIRD_PARTY_LICENSES.txt ] && cp THIRD_PARTY_LICENSES.txt "$DEST/"
|
||||
chmod +x "$DEST/autozhuyin_ibus.py"
|
||||
|
||||
# 3. Start with the desktop session: registers the engine with IBus and selects it.
|
||||
mkdir -p "$AUTOSTART"
|
||||
cat > "$AUTOSTART/autozhuyin.desktop" <<DESKTOP
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=自動注音 AutoZhuyin
|
||||
Comment=Registers the AutoZhuyin input method with IBus
|
||||
Exec=$PY $DEST/autozhuyin_ibus.py --activate
|
||||
Icon=$DEST/icon.png
|
||||
X-GNOME-Autostart-enabled=true
|
||||
X-KDE-autostart-phase=2
|
||||
NoDisplay=true
|
||||
DESKTOP
|
||||
|
||||
# 4. Start it now as well.
|
||||
if pgrep -x ibus-daemon >/dev/null 2>&1; then
|
||||
nohup "$PY" "$DEST/autozhuyin_ibus.py" --activate >/dev/null 2>&1 &
|
||||
sleep 1
|
||||
echo "已啟動並切換到自動注音。"
|
||||
else
|
||||
echo "IBus 目前沒有在執行,請照下面的步驟啟用 IBus 後登出再登入。"
|
||||
fi
|
||||
|
||||
cat <<'MSG'
|
||||
|
||||
安裝完成。
|
||||
- KDE(Bazzite / SteamOS 桌面模式):系統設定 → 鍵盤 → 虛擬鍵盤,選「IBus Wayland」,
|
||||
按套用後登出再登入。之後每次登入都會自動切換到自動注音。
|
||||
- 想暫時改回一般鍵盤:ibus engine xkb:us::eng ;切回自動注音:ibus engine autozhuyin
|
||||
- 移除:執行 uninstall.sh
|
||||
MSG
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Removes AutoZhuyin (自動注音) for the current user. Your learned corrections and
|
||||
# user phrases in ~/.config/autozhuyin are kept (delete that folder to remove them).
|
||||
set -uo pipefail
|
||||
|
||||
DEST="${XDG_DATA_HOME:-$HOME/.local/share}/autozhuyin"
|
||||
AUTOSTART="${XDG_CONFIG_HOME:-$HOME/.config}/autostart/autozhuyin.desktop"
|
||||
|
||||
if command -v ibus >/dev/null 2>&1 && [ "$(ibus engine 2>/dev/null)" = "autozhuyin" ]; then
|
||||
ibus engine xkb:us::eng 2>/dev/null
|
||||
fi
|
||||
pkill -f "autozhuyin/autozhuyin_ibus.py" 2>/dev/null
|
||||
rm -rf "$DEST" "$AUTOSTART"
|
||||
echo "已移除自動注音。學習紀錄留在 ~/.config/autozhuyin,不需要可以自行刪除。"
|
||||
Reference in New Issue
Block a user