forked from ChestnutHeng/Wudao-dict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·64 lines (55 loc) · 1.72 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
DESKTOP_ENTRY="/usr/share/applications/"
INSTALL_PATH="/usr/bin"
COMPLETION_PATH="/etc/bash_completion.d"
COLOR_RED='\033[31m'
COLOR_RESET='\033[0m'
if [ ! `pwd | grep wudao` ]
then
cd wudao-dict 2> /dev/null
if [ ! `pwd | grep wudao` ] ; then
echo -e "${COLOR_RED}请进入 Wudao-dict/wudao-dict 再运行此脚本${COLOR_RESET}"
echo -e "${COLOR_RED}终止安装${COLOR_RESET}"
exit 1
fi
fi
# 安装依赖
pip3 install pyqt5 bs4 lxml
# 用户词
if [ ! -d user ]
then
mkdir user
fi
chmod -R 777 user
# 添加系统命令wd
echo '#!/bin/bash'>./wd
echo 'save_path="$PWD"'>>./wd
echo 'cd '$PWD >>./wd
echo 'python3 WudaoCommand.py $*'>>./wd
echo 'ErrorCode="$?"'>>./wd
echo 'cd "$save_path"'>>./wd
echo 'exit $ErrorCode'>>./wd
chmod +x ./wd
sudo mv ./wd $INSTALL_PATH/wd
# 添加桌面GUI图标
echo '[Desktop Entry]' > ./wudao.desktop
echo 'Name=Wudao' >> ./wudao.desktop
echo 'Name[zh_CN]=无道词典' >> ./wudao.desktop
echo 'Comment=Youdao is wudao, a powerful dict.' >> ./wudao.desktop
echo 'Comment[zh_CN]=有道即无道,一个强大的词典。' >> ./wudao.desktop
echo "Exec=python3 $PWD/mainwindow.py" >> ./wudao.desktop
echo "Path=$PWD" >> ./wudao.desktop
echo "Icon=$PWD/Logo.ico" >> ./wudao.desktop
echo 'Terminal=false' >> ./wudao.desktop
echo 'Type=Application' >> ./wudao.desktop
echo 'Categories=Utility' >> ./wudao.desktop
sudo rm $DESKTOP_ENTRY/wudao.desktop
sudo mv ./wudao.desktop $DESKTOP_ENTRY
# 添加自动补全
sudo rm -f $COMPLETION_PATH/wd
sudo cp wd_com $COMPLETION_PATH/wd
. $COMPLETION_PATH/wd
echo 'Setup Finished! '
echo 'use wd [OPTION]... [WORD] to query the word.'
echo '自动补全会在下次打开命令行时启用'
echo '或者手动运行 source ~/.bashrc'