#!/bin/bash
export PATH=$PATH:/sbin
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=Deepin
export DDE_CURRENT_COMPOSITOR=GXWM
export GXWM_DONOT_BROADCAST_TLPM=ON
export KYWC_USE_LAYOUT_MANAGER=1  # 设置环境变量这个才会使用配置文件里的分辨率
unset QT_QPA_PLATFORM
unset DTK2_XWAYLAND

# The logic of libseat is that seatd is the 1st priority backend, and then
# logind. We are currently using LightDM with logind (The current developing
# GXDE Display manager is based on SDDM, which is also using logind), and hence
# we are forcing the backend to logind.
#
# Unfortunately, we're unable to auto detect which one to use automatically.
#
# Don't be overwhelmed if you are a seatd user. If you are really using seatd,
# You may simply comment out the following if block.
# -----------------------------------------------------------------------------
# libseat的逻辑如下：在有Seatd的情况下优先使用seatd，而GXDE（无论是当前GXDE正在使用的
# LightDM还是正在开发的基于SDDM的GXDE Display Manager）都使用logind。故而我们强制使用
# logind作为后端。
#
# 不幸的是，我们无法自动检测应该使用哪个后端。
#
# 如果您是seatd用户，您也无须担心，只需要注释掉下方这个if块即可。
if [ -z "$LIBSEAT_BACKEND" ] && [ -n "$XDG_SESSION_ID" ] && [ -d /run/systemd/seats ]; then
    export LIBSEAT_BACKEND=logind
fi

# export GDK_BACKEND=wayland
# export WLR_DRM_NO_ATOMIC=1

# === gxde-hisi-9000c-gpu-compat: kirin 9000c 芯片走 hisi 硬件桌面 ===
# 检测到麒麟 9000c 内核且安装了 gxde-hisi-9000c-gpu-compat（提供
# /usr/bin/startgxde_wlcom_hisi9000c，hisi Maleoon 910 硬件加速）时，
# 跳转到该启动器；否则走默认软件路径。
if [ -x /usr/bin/startgxde_wlcom_hisi9000c ] && uname -r | grep -q 9000c; then
    exec /usr/bin/startgxde_wlcom_hisi9000c "$@"
fi

exec /usr/bin/gxde-wlcom -s /usr/bin/startdde "$@"
