#! /bin/bash
unset LD_LIBRARY_PATH 
unset QT_QPA_PLATFORM_PLUGIN_PATH 
unset QML2_IMPORT_PATH
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_SHELL_INTEGRATION=kwayland-shell

#export DDE_DEBUG_LEVEL=debug
export QT_LOGGING_RULES="*.debug=false;*.info=false"

## 屏蔽此环境变量，应用的文管弹窗是自研的文管弹窗 
#export _d_disable_filedialog=1

if [ -z "$DISPLAY" ]; then
  export DISPLAY=:0
fi
if [ -z "$WAYLAND_DISPLAY" ]; then
  export WAYLAND_DISPLAY=wayland-0
fi

if [ -f "$HOME/.dde_env" ]; then
  export_commands=$(awk '/^export/ {
    if (match ($0, /export (\w+)=\"([^"\\;]+)\";/, arr)) {
        if (arr[1] == "LANG" || arr[1] == "LANGUAGE") {
            print "export " arr[1] "=\"" arr[2] "\""
        }
    }
  }' ~/.dde_env)
  eval "$export_commands"
fi

name=`dmidecode -t 1 | awk '/Product Name:/{print $NF}'`
export SYS_PRODUCT_NAME=${name}

if [ -x "/usr/bin/dbus-update-activation-environment" ]; then
  # tell dbus-daemon --session (and systemd --user, if running)
  # to put a minimal subset of the Xsession's environment in activated
  # services' environments
  dbus-update-activation-environment --verbose --systemd --all
fi

if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
  exec dbus-launch /usr/bin/start_session.bash
else
  exec /usr/bin/start_session.bash
fi
