Last active
January 15, 2023 11:53
-
-
Save pcmid/8a12797a3cdc5a21dfff701919ef6be5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" | |
FONTCONFIG_HOME="${XDG_CONFIG_HOME}/fontconfig" | |
USER_RUN_DIR="/run/user/$(id -u)" | |
DOWNLOAD_DIR="$(xdg-user-dir DOWNLOAD)" | |
QQ_RUN_DIR="${USER_RUN_DIR}/QQ" | |
QQ_APP_DIR="${XDG_CONFIG_HOME}/QQ" | |
QQ_DOWNLOAD_DIR="$(xdg-user-dir DOWNLOAD)/QQ" | |
if [ ! -e "${QQ_RUN_DIR}" ]; then mkdir -p "${QQ_RUN_DIR}"; fi | |
if [ ! -e "${QQ_APP_DIR}" ]; then mkdir -p "${QQ_APP_DIR}"; fi | |
if [ ! -e "${QQ_DOWNLOAD_DIR}" ]; then mkdir -p "${QQ_DOWNLOAD_DIR}"; fi | |
exec {PWD_FD}< <(getent passwd $UID) | |
bwrap --new-session --clearenv --cap-drop ALL --unshare-all --share-net --die-with-parent --as-pid-1 \ | |
--dev /dev \ | |
--dev-bind /dev/dri /dev/dri \ | |
--proc /proc \ | |
--symlink usr/lib /lib \ | |
--symlink usr/lib64 /lib64 \ | |
--symlink usr/bin /bin \ | |
--ro-bind /usr /usr \ | |
--ro-bind /opt/QQ /opt/QQ \ | |
--ro-bind /etc/resolv.conf /etc/resolv.conf \ | |
--ro-bind /etc/localtime /etc/localtime \ | |
--ro-bind /etc/fonts /etc/fonts \ | |
--file ${PWD_FD} /etc/passwd \ | |
--ro-bind /run/dbus /run/dbus \ | |
--ro-bind-try ${USER_RUN_DIR}/bus ${USER_RUN_DIR}/bus \ | |
--ro-bind-try "${XAUTHORITY}" "${XAUTHORITY}" \ | |
--ro-bind-try "${HOME}/.icons" "${HOME}/.icons" \ | |
--ro-bind-try "${HOME}/local/share/.icons" "${HOME}/local/share/.icons" \ | |
--ro-bind-try "${XDG_CONFIG_HOME}/gtk-3.0" "${XDG_CONFIG_HOME}/gtk-3.0" \ | |
--ro-bind-try "${FONTCONFIG_HOME}" "${FONTCONFIG_HOME}" \ | |
--bind "${QQ_DOWNLOAD_DIR}" "${DOWNLOAD_DIR}" \ | |
--bind "${QQ_APP_DIR}" "${QQ_APP_DIR}" \ | |
--tmpfs "${QQ_APP_DIR}/crash_files" \ | |
--tmpfs "${QQ_APP_DIR}/log" \ | |
--tmpfs "${QQ_APP_DIR}/logs" \ | |
--tmpfs "${QQ_APP_DIR}/Crashpad/pending" \ | |
--tmpfs "${QQ_APP_DIR}/global/nt_data/Log" \ | |
--bind /dev/null "${QQ_APP_DIR}/versions/major.log" \ | |
--setenv DISPLAY ${DISPLAY} \ | |
--setenv HOME ${HOME} \ | |
--setenv XAUTHORITY ${XAUTHORITY} \ | |
--setenv DBUS_SESSION_BUS_ADDRESS ${DBUS_SESSION_BUS_ADDRESS} \ | |
--setenv IBUS_USE_PORTAL 1 \ | |
/opt/QQ/qq $@ | |
exec {PWD_FD}>&- | |
rm -rf "${QQ_APP_DIR}/nt_qq_"*"/nt_data/log"* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment