11

修复 wine 微信黑色色块问题

 2 years ago
source link: https://blog.diqigan.cn/posts/wine-wechat-black-square-fix.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

如果你看不懂标题,那么恭喜你,没有遇到这个心烦的问题.

Linux 下使用 wine 微信有一定概率会出现烦人的黑色色块,看它不爽,却又无可奈何,极大地影响了用户体验。刚好在 github 看到了一个解决方案,整理记录至此.

编辑本文时笔者电脑的环境是:

  • Ubuntu 19.10
  • deepin-wine-ubuntu 2018-12-ubuntu3
  • deepin-wine-wechat

其他环境请自行举一反三.

安装 xdotool

因为后面的脚本要使用到 xdotool 这个工具,此处需要先行安装:

sudo apt-get install xdotool

wine 微信启动脚本

新建脚本文件 “run-wechat.sh”, 写入如下内容:

#!/bin/bash
"/opt/deepinwine/apps/Deepin-WeChat/run.sh">/dev/null 2>&1
start_succ=false
for i in {1..5}
do
xdotool search --onlyvisible --classname "WeChat.exe"
if [ $? == 0 ]
then
start_succ=true
break
fi
sleep 10
done
if [ $start_succ == false ]
then
exit 1
fi
windowclose=false
while :
do
retval=$(xdotool search --onlyvisible --classname "WeChat.exe")

if [ $? != 0 ]
then
exit 0
fi
login=true
for id in $retval
do
windowname=$(xdotool getwindowname $id)
if [ "$windowname" == "登录" ]
then
login=false
fi

if [ $windowclose == true ] && ([ "$windowname" == "" ] || [ "$windowname" == "ChatContactMenu" ])
then
xdotool windowclose $id
fi
done

if [ $windowclose == true ]
then
exit 0
fi
if [ $login == true ]
then
windowclose=true
fi
sleep 2
done

给脚本添加可执行权限:

chmod +x ./run-wechat.sh

此时脚本设置完成,可以尝试执行此脚本。脚本会在微信成功登录之后关闭黑色色块.

修改微信快捷方式

找到微信的快捷方式,deepin-wine-wechat 的快捷方式为 /usr/share/applications/deepin.com.wechat.desktop, 将 desktop 文件中 Exec 一行修改为:

Exec="${path}/run-wechat.sh" -u %u

${path} 表示 run-wechat.sh 脚本所在路径.

至此,就可以通过快捷方式启动微信,并且摆脱黑色色块的烦扰了.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK