#!/bin/bash
# 在network阶段配置desktop /etc/environment 环境变量

. /usr/share/bianbu-config/common

if is_script_executed; then
    exit 0
fi

configure_desktop_env_libreOffice() {
    log_info "/etc/environment: set SAL_USE_VCLPLUGIN=qt6 for libreOffice"
    if [ -f /etc/environment ]; then
        # 检查是否已经存在该变量
        if ! grep -q "SAL_USE_VCLPLUGIN=qt6" /etc/environment; then
            # 如果不存在，则添加
            echo "SAL_USE_VCLPLUGIN=qt6" >> /etc/environment
        fi

    else
        # 如果文件不存在，则创建并添加变量
        touch /etc/environment
        echo "SAL_USE_VCLPLUGIN=qt6" >> /etc/environment
    fi
}

IFS=' ' read -r _ board <<<"$(detect)"

case "${board}" in
*)    
    configure_desktop_env_libreOffice
    ;;
esac

mark_script_executed

