1. 程式人生 > >劃詞翻譯軟體

劃詞翻譯軟體

專案主頁

https://github.com/bianjp/popup-dict/

安裝:

sudo apt-get install popup-dict

繫結快捷鍵命令

#!/bin/sh

PS_KEYWORD=popup-dict
PS_KEYWORD0=python3
PROCESS=/usr/local/bin/popup-dict

case $1 in
    start)
        ps aux |grep -v grep | grep ${PS_KEYWORD} | grep ${PS_KEYWORD0} -q
            if [ $? -ne 0 ]; then
                ${PROCESS} 2>&1 > /dev/null &
                export DISPLAY=:0.0 && /usr/bin/notify-send -i accessories-dictionary "On" "popup-dict on"
            fi
        ;;

    stop)
        for pid in `pidof ${PS_KEYWORD0}`;do 
            grep -q ${PS_KEYWORD} /proc/${pid}/cmdline
            if [ $? -eq 0 ]; then
                export DISPLAY=:0.0 && /usr/bin/notify-send -i accessories-dictionary "Off" "popup-dict off"
                kill ${pid}
            fi
        done;
        ;;
        switch)
                ps aux |grep -v grep | grep ${PS_KEYWORD} | grep ${PS_KEYWORD0} -q
                        if [ $? -ne 0 ]; then
                                #if offline, turn it on
                                $0 start
                        else
                                #else online, turn it off
                                $0 stop
                        fi
                ;;

    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
esac

exit 0

deepin 快捷鍵繫結有bug

快捷鍵配置檔案: ~/.config/deepin/dde-daemon/keybinding/custom.ini

  • 填寫命令介面內設定快捷用複雜的快捷鍵,例如: ctrl+alt+shift+e, 保證一次性填完,不要修改,否則命令內容會消失

  • 儲存出到主介面後再修改快捷鍵

缺點

只能取詞,不能整段翻譯, 只有詞庫中的有的單詞才會出現翻譯框, 劃無意義的字母組合不會有彈窗