提前声明:此脚本是在安装完官方原版linuxmint22.3cinnamon之后,先安装了fcitx5输入法,然后直接执行的,系统配置文件没有被污染,请先执行菜单无法输入中文的一键修复脚本,再进行如下操作:
#!/usr/bin/env python3# -*- coding: utf-8 -*-import subprocessimport osdef run(cmd):subprocess.run(cmd, shell=True, check=False)print("🔧 正在修复微信无法输入中文...")# 1. 修复微信启动文件环境变量run("sudo sed -i 's|^Exec=.*|Exec=env GTK_IM_MODULE=fcitx QT_IM_MODULE=fcitx XMODIFIERS=@im=fcitx /usr/bin/wechat %U|' /usr/share/applications/wechat.desktop")# 2. 写入全局环境变量path = os.path.expanduser("~/.xprofile")with open(path, "a", encoding="utf-8") as f:f.write("""export GTK_IM_MODULE=fcitxexport QT_IM_MODULE=fcitxexport XMODIFIERS=@im=fcitx""")run("chmod +x ~/.xprofile")run("source ~/.xprofile")# 3. 重启微信run("pkill wechat 2>/dev/null")run("nohup wechat >/dev/null 2>&1 &")print("✅ 修复完成!微信已重启,现在可以输入中文了。")print("💡 如仍不行,请注销/重启一次系统。")# 防止自动关闭input("\n按回车退出")
然后在fix_wechat.py文件所在的文件夹中右击鼠标,打开终端,执行命令
python3 fix_wechat.py执行完后注销或重启系统后即生效。
linuxmint中文版交流群开通,欢迎大家加入,QQ群号:1014439331
