Skip to content

Commit

Permalink
workaround for fcitx & ibus, support cam
Browse files Browse the repository at this point in the history
also cleaned up dev node binding logic

Co-authored-by: devome <evinedeng@hotmail.com>
  • Loading branch information
7Ji and devome committed Mar 15, 2024
1 parent 30518e2 commit 37a911c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .SRCINFO
@@ -1,7 +1,7 @@
pkgbase = wechat-universal-bwrap
pkgdesc = WeChat (Universal) with bwrap sandbox
pkgver = 1.0.0.238
pkgrel = 5
pkgrel = 6
url = https://weixin.qq.com
arch = x86_64
arch = aarch64
Expand Down Expand Up @@ -42,7 +42,7 @@ pkgbase = wechat-universal-bwrap
source = wechat-universal.desktop
sha256sums = fcfa289c30685d9adb5d051f2d9e9883a4940655f2ce38c2db6241b78228a1d5
sha256sums = 53760079c1a5b58f2fa3d5effe1ed35239590b288841d812229ef4e55b2dbd69
sha256sums = b8c21b52205197c68161c91f0eeb0b1dd698a768fb53ea9e0ce55e0b2526f658
sha256sums = 78726d6c1a0e6a1e5bd911c42686e5244be8aac6e4c0a4abd2d5eb07ac43a3f6
sha256sums = b783b7b0035efb5a0fcb4ddba6446f645a4911e4a9f71475e408a5c87ef04c30
source_x86_64 = wechat-universal_1.0.0.238_x86_64.deb::https://home-store-packages.uniontech.com/appstore/pool/appstore/c/com.tencent.wechat/com.tencent.wechat_1.0.0.238_amd64.deb
sha256sums_x86_64 = 371026679dba25a033023b4077dc527059d906ec03ea2db05f6fc012ab40c96b
Expand Down
4 changes: 2 additions & 2 deletions PKGBUILD
Expand Up @@ -5,7 +5,7 @@
_pkgname=wechat-universal
pkgname=${_pkgname}-bwrap
pkgver=1.0.0.238
pkgrel=5
pkgrel=6
pkgdesc="WeChat (Universal) with bwrap sandbox"
arch=('x86_64' 'aarch64' 'loong64')
url="https://weixin.qq.com"
Expand Down Expand Up @@ -62,7 +62,7 @@ noextract=("${_deb_stem}"_{x86_64,aarch64,loong64}.deb)
sha256sums=(
'fcfa289c30685d9adb5d051f2d9e9883a4940655f2ce38c2db6241b78228a1d5'
'53760079c1a5b58f2fa3d5effe1ed35239590b288841d812229ef4e55b2dbd69'
'b8c21b52205197c68161c91f0eeb0b1dd698a768fb53ea9e0ce55e0b2526f658'
'78726d6c1a0e6a1e5bd911c42686e5244be8aac6e4c0a4abd2d5eb07ac43a3f6'
'b783b7b0035efb5a0fcb4ddba6446f645a4911e4a9f71475e408a5c87ef04c30'
)

Expand Down
38 changes: 33 additions & 5 deletions wechat-universal.sh
Expand Up @@ -13,9 +13,29 @@ env_add() {
BWRAP_ENV_APPEND+=(--setenv "$1" "$2")
}
BWRAP_ENV_APPEND=()
# wechat-universal only support xcb
# wechat-universal only supports xcb
env_add QT_QPA_PLATFORM xcb
env_add PATH "/sandbox:${PATH}"
env_add LC_ALL C

case "${XMODIFIERS}" in
*@im=fcitx*)
echo "Workaround for fcitx applied"
env_add QT_IM_MODULE fcitx
env_add GTK_IM_MODULE fcitx
;;
*@im=ibus*)
echo "Workaround for ibus applied"
env_add QT_IM_MODULE ibus
env_add GTK_IM_MODULE ibus
env_add IBUS_USE_PORTAL 1
;;
esac

BWRAP_DEV_BINDS=()
for DEV_NODE in /dev/{nvidia{-uvm,ctl,*[0-9]},video*[0-9]}; do
[[ -e "${DEV_NODE}" ]] && BWRAP_DEV_BINDS+=(--dev-bind "${DEV_NODE}"{,})
done

mkdir -p "${WECHAT_FILES_DIR}" "${WECHAT_HOME_DIR}"
ln -snf "${WECHAT_FILES_DIR}" "${WECHAT_HOME_DIR}/xwechat_files"
Expand All @@ -26,45 +46,52 @@ BWRAP_ARGS=(
--share-net
--cap-drop ALL
--die-with-parent

# /usr
--ro-bind /usr{,}
--symlink usr/lib /lib
--symlink usr/lib /lib64
--symlink usr/bin /bin
--symlink usr/bin /sbin
--bind /usr/bin/{true,lsblk}

# /sandbox
--ro-bind /{usr/lib/flatpak-xdg-utils,sandbox}/xdg-open
--ro-bind /{usr/share/wechat-universal/usr/bin,sandbox}/dde-file-manager

# /dev
--dev /dev
--dev-bind /dev/dri{,}
--dev-bind-try /dev/nvidiactl{,}
--dev-bind-try /dev/nvidia0{,}
--dev-bind-try /dev/nvidia-uvm{,}
--tmpfs /dev/shm

# /proc
--proc /proc

# /etc
--ro-bind /etc/machine-id{,}
--ro-bind /etc/passwd{,}
--ro-bind /etc/nsswitch.conf{,}
--ro-bind /etc/resolv.conf{,}
--ro-bind /etc/localtime{,}
--ro-bind-try /etc/fonts{,}

# /sys
--dir /sys/dev # hack for Intel / AMD graphics, mesa calling virtual nodes needs /sys/dev being 0755
--ro-bind /sys/dev/char{,}
--ro-bind /sys/devices{,}

# /tmp
--tmpfs /tmp

# /opt, Wechat-beta itself
--ro-bind /opt/wechat-universal{,}

# license fixups in various places
--ro-bind {/usr/share/wechat-universal,}/usr/lib/license
--ro-bind {/usr/share/wechat-universal,}/var/
--ro-bind {/usr/share/wechat-universal,}/etc/os-release
--ro-bind {/usr/share/wechat-universal,}/etc/lsb-release

# /home
--bind "${WECHAT_HOME_DIR}" "${HOME}"
--bind "${WECHAT_FILES_DIR}"{,}
Expand All @@ -75,6 +102,7 @@ BWRAP_ARGS=(
--ro-bind-try "${HOME}/.local/share/fonts"{,}
--ro-bind-try "${HOME}/.icons"{,}
--ro-bind-try "${HOME}/.local/share/.icons"{,}

# /run
--dev-bind /run/dbus{,}
--ro-bind /run/systemd/userdb{,}
Expand All @@ -83,4 +111,4 @@ BWRAP_ARGS=(
--ro-bind "${XDG_RUNTIME_DIR}/pulse"{,}
)

exec bwrap "${BWRAP_ARGS[@]}" "${BWRAP_ENV_APPEND[@]}" /opt/wechat-universal/wechat "$@"
exec bwrap "${BWRAP_ARGS[@]}" "${BWRAP_DEV_BINDS[@]}" "${BWRAP_ENV_APPEND[@]}" /opt/wechat-universal/wechat "$@"

0 comments on commit 37a911c

Please sign in to comment.