Skip to content

Commit

Permalink
init repo
Browse files Browse the repository at this point in the history
  • Loading branch information
KZ25T committed Apr 22, 2024
0 parents commit e60fdd6
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 0 deletions.
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# 微信 AppImage

使用 AppImage 运行 Linux 原生微信

- 无需安装
- 规避原微信的不可卸载特性
- 无需更改系统的 `lsb-release``/etc` 内的文件
- 无需 sudo
- 限制读写目录,以防在操作系统里到处乱放文件

## 使用前提

- 需要安装 bwrap(常见发行版都有)
- 需要有 XDG 用户目录(常见发行版都有)
- 查看 `~/.config/user-dirs.dirs`(必须有这个文件)
- 里面要有 `XDG_DESKTOP_DIR``XDG_DOWNLOAD_DIR``XDG_DOCUMENTS_DIR`
- 运行时,在用户目录下,微信只能读写这三个目录、微信数据库文件(放在 `${XDG_DOCUMENTS_DIR}/xwechat_files` 下,原生微信是 `~/xwechat_files`)、微信配置文件(`~/.xwechat`)和字体配置文件。

## 获取 AppImage 文件

### 从 release 下载

在本仓库 release 下载 x86_64 版,该版本基于[吾爱破解](https://www.52pojie.cn/thread-1896902-1-1.html)给出的 238 版构建。下载后记得给执行权限。

### 自行构建

以下构建方式仅测试过 238 的 x86_64 版。

下载本仓库,同时下载一个微信 Linux 版本的 deb 包。

解包 deb,移植文件:

```bash
# pwd 为仓库根目录
dpkg -X your_wechat.deb /tmp/out
cp -r /tmp/out/opt src # 大部分文件
cp -r /tmp/out/usr/lib src/usr # 应该只有 libactivation.so
```

安装 appimagetool(自己上网搜)

打包 appimage:

```bash
# pwd 为仓库根目录上一级
appimagetool ./wechat-appimage
```

可以取得 `wechat-x86_64.AppImage`

## 运行方法

已经测试在 Debian 和 kali 运行过。

注:实际测试中有极少时候第一次扫码之后没反应,此时可以关闭重新启动扫码。

### 简单运行

直接双击此文件或者命令行启动即可。

### 安装运行

```bash
sudo mv wechat-x86_64.AppImage /usr/bin/wechat
sudo wechat --install # 安装图标
```

然后你可以在桌面添加类似的启动器图标。

### 更多功能

```bash
# 帮助
wechat-x86_64.AppImage --help
# 进入 bwrap 的 shell(bash)
wechat-x86_64.AppImage --debug
# 关闭微信进程(早期版本无法退出,现在应该没了)
wechat-x86_64.AppImage --kill
# 安装图标
sudo wechat-x86_64.AppImage --install
```

## 声明

未经过严格测试,使用本仓库造成的一切后果由使用者负责。
85 changes: 85 additions & 0 deletions src/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash
export PATH="$APPDIR/opt/wechat-beta:$PATH"
export LD_LIBRARY_PATH="$APPDIR/opt/wechat-beta:$APPDIR/usr/lib"
export LANG=zh_CN.UTF-8
EXEC="wechat"
if [ $# -eq 1 ]; then
if [ "$1" = "help" -o "$1" = "--help" ]; then
echo "Run wechat without options"
echo "Options:"
echo " --debug return a shell but not wechat"
echo " --kill to kill wechat process"
echo " --install(root required) to install desktop file to /usr/share/applications"
exit $?
fi
if [ "$1" = "--debug" ]; then
EXEC="bash"
fi
if [ "$1" = "--kill" ]; then
kill $(ps -e | grep wechat | grep -v "wechat-" | awk '{print $1}')
exit $?
fi
if [ "$1" = "--install" ]; then
cp $APPDIR/usr/share/applications/wechat.desktop /usr/share/applications
cp $APPDIR/usr/share/icons/hicolor/256x256/apps/wechat.png /usr/share/icons/hicolor/256x256/apps
exit $?
fi
fi
# wechat-beta only support xcb
BWRAP_ENV_APPEND="--setenv QT_QPA_PLATFORM xcb "
if [ -z ${QT_IM_MODULE} ]; then
BWRAP_ENV_APPEND="${BWRAP_ENV_APPEND} --setenv QT_IM_MODULE fcitx"
fi
if [ -z ${GTK_USE_PORTAL} ]; then
BWRAP_ENV_APPEND="${BWRAP_ENV_APPEND} --setenv GTK_USE_PORTAL 1"
fi
# append user config file
BWRAP_FILE_APPEND=""
if [ -e ~/.config/user-dirs.dirs ]; then
source ~/.config/user-dirs.dirs
WECHAT_CFG_DIR=${XDG_DOCUMENTS_DIR}/xwechat_files
mkdir -p ${WECHAT_CFG_DIR}
BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${XDG_DESKTOP_DIR} ${XDG_DESKTOP_DIR} "
BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${XDG_DOCUMENTS_DIR} ${XDG_DOCUMENTS_DIR} "
BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${XDG_DOWNLOAD_DIR} ${XDG_DOWNLOAD_DIR} "
BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${WECHAT_CFG_DIR} $HOME/xwechat_files "
else
echo ">>>>> WARNING: no xdg config file (~/.config/user-dirs.dirs) found."
echo ">>>>> YOU SHOULD CONFIG IT but now wechat will try continue to run."
fi
FONT1=$HOME/.cache/fontconfig
FONT2=$HOME/.config/fontconfig
if [ -e ${FONT1} ]; then
BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${FONT1} ${FONT1} "
fi
if [ -e ${FONT2} ]; then
BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${FONT2} ${FONT2} "
fi
mkdir -p $HOME/.xwechat
bwrap --die-with-parent \
--ro-bind / / \
--tmpfs /sys --tmpfs /home --tmpfs /etc --proc /proc \
--tmpfs /run --tmpfs /usr/lib --tmpfs /tmp --dev /dev \
--ro-bind $APPDIR $APPDIR \
--ro-bind $APPDIR/etc/os-release /etc/os-release \
--ro-bind $APPDIR/etc/lsb-release /etc/lsb-release \
--ro-bind $APPDIR/etc/.kyact /etc/.kyact \
--ro-bind $APPDIR/etc/LICENSE /etc/LICENSE \
--ro-bind /etc/alternatives /etc/alternatives \
--ro-bind /etc/fonts /etc/fonts \
--ro-bind /etc/hostname /etc/hostname \
--ro-bind /etc/hosts /etc/hosts \
--ro-bind /etc/ld.so.cache /etc/ld.so.cache \
--ro-bind /etc/localtime /etc/localtime \
--ro-bind /etc/passwd /etc/passwd \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--ro-bind $APPDIR/usr/lib/libactivation.so /usr/lib/libactivation.so \
--ro-bind /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu \
--ro-bind /usr/lib/udev /usr/lib/udev \
--ro-bind /run/user/$UID /run/user/$UID \
--bind $HOME/.xwechat $HOME/.xwechat \
${BWRAP_FILE_APPEND} \
${BWRAP_ENV_APPEND} \
${EXEC}
# refer: https://blog.lilydjwg.me/2021/8/12/using-bwrap.215869.html
# refer: https://github.com/lfift/wechat-beta-bwrap/blob/main/wechat.sh
5 changes: 5 additions & 0 deletions src/etc/.kyact
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
systemuuid=25ef0280-ec82-42b0-8fb6-10adccc67c02
netmac=00:07:3e:9c:2e:43
registernum=WCYU-3AS2-Q7LP-HWH6-SJPZ
serialnum=27734012
harddisk=WDC-PC-SN530-SDBPNPZ-512G_204485805972
19 changes: 19 additions & 0 deletions src/etc/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

TO:麒麟软件内部版本
SERIAL:100000
TERM:2021-08-29
CLASS:desktop
VERSION:Desktop
PLATFORM:x86_64
OSNAME:Kylin V10 SP1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iJwEAQECAAYFAmEDwk8ACgkQLRr+uL6cqPu6xAP/QRty0END7q0VxbbwgoKYefHk
VJF9F7SFSU5FGVUyR0pLmKzAMAmi+9xhbGw5tGp2XLIBOJHayK6TGhdpgvP+wT6s
0QLrh3c7HZhM0maoo6ZNR07bYzXXPcrMt6qTgaSRQnV+zfARn9+e2Ub5xfBfphtk
KHL1Nd4NRj0aICyjlys=
=6SEp
-----END PGP SIGNATURE-----
7 changes: 7 additions & 0 deletions src/etc/lsb-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DISTRIB_ID=Kylin
DISTRIB_RELEASE=V10
DISTRIB_CODENAME=kylin
DISTRIB_DESCRIPTION="Kylin V10 SP1"
DISTRIB_KYLIN_RELEASE=V10
DISTRIB_VERSION_TYPE=enterprise
DISTRIB_VERSION_MODE=normal
6 changes: 6 additions & 0 deletions src/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NAME="Kylin Linux Advanced Server"
VERSION="V10 (Tercel)"
ID="kylin"
VERSION_ID="V10"
PRETTY_NAME="Kylin Linux Advanced Server V10 (Tercel)"
ANSI_COLOR="0;31"
9 changes: 9 additions & 0 deletions src/usr/share/applications/wechat.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=微信
Exec=wechat %U
StartupNotify=true
Terminal=false
Icon=/usr/share/icons/hicolor/256x256/apps/wechat.png
Type=Application
Categories=Utility;
Comment=微信桌面版
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/wechat.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Name=wechat
StartupNotify=true
Terminal=false
Icon=wechat
Type=Application
Categories=Utility;
Comment=微信桌面版
Binary file added src/wechat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e60fdd6

Please sign in to comment.