Install deepin-wine QQ inside a docker image in Ubuntu 20.04

在Ubuntu中想要拥有一个稳定可用的QQ/微信一直不是一件容易的事。腾讯官方于2019年10月24日发布了QQ for Linux,但界面复古,一股浓浓的QQ2009气息,功能也有限,而这些其实都是次要的,关键问题是在我的机器上它几乎总是一登录就闪退(室友的Ubuntu 18.04上似乎运行得还可以),使得哪怕是最复古原始的功能也无法正常使用。

然后在2021年4月,VSCode用户的福音来了,有人发布了一个vscode-qq extension,可以在VSCode里使用QQ。虽然功能和官方的QQ for Linux差不多原始,但至少是一个能稳定运行的东西。

不知道各位用QQ主要是为了什么,在我看来最重要的其实是截图和传文件两大功能,QQ在这两个方面带来的便捷性无与伦比。然而vscode-qq并没有提供这样的功能,所以其实还是无法满足我的需求。

在网上搜到过一些用Wine装QQ的方法,也自己尝试过,但会遇到各种问题,例如字体加载不出来、中文字全是方框、卡顿、界面显示不全等等。后来看到了https://github.com/zq1997/deepin-wine这个项目,按照它的方法安装了deepin-wine TIM,非常成功,用起来很丝滑,除了音视频和远程功能受限之外,其他方面的体验几乎与Windows无异。这里说一句,我更prefer TIM而非QQ,因为TIM是一个窗口而QQ是两个窗口,在Ubuntu wine或者deepin-wine下这些窗口乱蹦乱跳实在是很烦人的事情;而且QQ会加载很多我平常不需要的功能,加载得越多我越害怕,怕它突然遭遇什么不测而卡死,毕竟这不是Windows。

用上面的办法安装微信也OK,但我实践后发现微信遇到了一些TIM没有的问题,例如截图和发送图片功能的异常,以及鼠标focus到其它窗口时微信的窗口仍然固执地挡在那里。毕竟不是直接装在系统上,遇到各种奇怪的问题也是在情理之中。所以读者如果按照我后面介绍的方法做了之后没有达到很好的效果,可以尝试去搜一些解决方法,但请坚持“能用就好”的原则。

虽然安装deepin-wine TIM/WeChat的过程总体来说比较成功,但遗憾的是后来我再也没能复刻出来,不论是帮同学安装,在VMware虚拟机上或在真实的系统上,还是在我自己硬盘烧了之后那个重装系统的悲伤夜晚,我都没能用这个方法重新安装出来,每一次一登录就会立刻卡死,未响应,遇到问题,是否发送问题报告…

最终我找到了docker。docker是一个很不错的用来安装和管理环境的工具,它的好处是可以将各个环境与外部系统相互之间隔离开,有点像一个小型虚拟机的意思,你可以随心所欲地定制你想要的环境,而且如果安装过程中出了什么问题也不至于把你本地的环境搞得乱七八糟。最后这点很重要,因为安装deepin-wine qq需要dpkg对i386 architecture的支持,然后会需要装一大堆i386的package,看着就眼晕。

Step 1

Follow the official guide to install Docker Engine.

Step 2

Follow the guide here download the QQ image (in fact it is TIM, which is more preferable as I said before) bestwu/qq:office. In the link above, the author mentioned two ways of running the container: using the docker run command with a long list of arguments, or making a docker-compose.yml file and use docker-compose. Personally I would recommend the latter one.

Two problems that may appear:

  • docker-compose command not found, but you have installed docker-compose-plugin. Just use docker compose instead (remove the hyphen).
  • Got Permission denied when executing docker whatever (e.g. docker images). A temporary solution is sudo chmod 666 /var/run/docker.sock, but you may find that you have to chmod this every time on boot. What’s more, such chmod actually gives all local users the read and write permissions to the docker socket, which brings about security issues and is not recommended. (But on a personal computer it is fine, I think.) See this answer for a real, permanent solution.

Step 3

Follow the guide directly and the login window will show up, but the version of TIM is too old, which may refuse to log in via password. You may still log in by scanning the QR code, but I successfully upgraded it following this issue.

Note that any changes to the docker image will not be preserved when you restart docker or reboot your system. To commit a change follow this link, or search about docker commit on your own.

Step 4

If everything goes on well, you should be able to use TIM smoothly now. But there’s one more thing, that the TIM is running inside a deepin-wine container in a docker container, whose file system is isolated from the outside real-world system. Therefore it is not supported to transfer files directly. To make TIM able to find your files, add the following item to the volumes list in docker-compose.yml:

- /home/username:/home/qq/username

Remember to change username to your user name.


In addition, you may also install WeChat from Ubuntu Kylin sources following this page. It works well, though lacking many functions.


2022.10.20 update

我个人是比较倾向于把各个软件的名字区分清楚的,所以我把这个image的名字改成了tim,虽然它里面的username还是qq

之前这样配置之后用着一直挺不错的,但唯独有一个问题:每次退出TIM之后这个docker image不会自动stop,如果想重新开需要手动docker stop或者docker restart,而这两个指令都莫名需要花很长的时间。STFW后知道:docker stop会首先给那个root process发送一个SIGTERM,然后在一定的时间内(比如10秒)如果它没有终止就发送SIGKILL杀死它。而docker restart就是先做了和docker stop一样的事情来关掉它再重启。仔细观察entrypoint.sh的后半段:

su qq <<EOF
   echo "启动 $APP"
   mkdir -p /home/qq/.deepinwine
   touch /home/qq/.deepinwine/.QQ_run
   "/opt/deepinwine/apps/Deepin-$APP/run.sh"
   sleep 300
EOF

#tail -fn 0 /home/qq/.deepinwine/.QQ_run
while test -n "`pidof QQProtect.exe`"
do
    sleep 60
done
echo "退出"

它先运行了一个名为run.sh的脚本,这个脚本会把整个TIM启动起来,然后非常诡异地sleep了五分钟。之后,它每隔一分钟就检测一下QQProtect.exe这个进程还存不存在,如果不存在就结束。

首先有个问题是,如果按照这个issue里的方案去升级了TIM,最新版的TIM的那个进程并不是QQProtect.exe而是QQExternal.exe,所以我们的entrypoint.sh里也需要作相应的修改。此外,不知道是不是跟升级TIM有关,但这个run.sh在原地运行之后并不会自己结束或者放入后台,导致从sleep 300开始后面这一段代码根本没有执行。一个简单的办法就是直接把它放入后台,但我其实担心有一天它出锅了我可能会需要它输出的信息,所以我最终决定在后台运行另一个进程:

#!/bin/bash

echo "observer starts."
while ! test -n "`pidof QQExternal.exe`"
do
    sleep 1
done
echo "QQExternal.exe has started."
while test -n "`pidof QQExternal.exe`"
do
    sleep 1
done
echo "QQExternal.exe has stopped."
pkill run.sh
if test -n "pidof run.sh"
then
    echo "killing run.sh failed."
else
    echo "run.sh is killed."
fi

修改后的entrypoint.sh

#!/bin/bash

groupmod -o -g $AUDIO_GID audio
groupmod -o -g $VIDEO_GID video

if [ $GID != $(echo `id -g qq`) ]; then
    groupmod -o -g $GID qq
fi
if [ $UID != $(echo `id -u qq`) ]; then
    usermod -o -u $UID qq
fi
chown qq:qq /TencentFiles

su qq <<EOF
   echo "启动 $APP"
   mkdir -p /home/qq/.deepinwine
   touch /home/qq/.deepinwine/.QQ_run
   ./observer.sh > /home/qq/observer_output.txt &
   "/opt/deepinwine/apps/Deepin-$APP/run.sh"
   echo "run.sh has been killed."
EOF

echo "exit"

我在运行run.sh之前先开始执行observer.sh并放进后台。observer.sh会首先等待QQExternal.exe启动,然后不断地检查它有没有终止,一旦发现它终止了就直接把run.sh杀死。

注:为了编辑这里面的脚本,你需要先docker exec -it tim bash,然后apt update,再apt install vim安装VIM。改完不要忘了commit。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值