import logging
import os
import subprocess

import flandre
from flandre import C
from flandre.nodes.MainUI import MainUI


def kde_pyqt6_mainui(software_config):
    flandre.C.write_config()
    subprocess.run(['python', __file__],
                   env=dict(XDG_CURRENT_DESKTOP="KDE",
                            XDG_RUNTIME_DIR="/run/user/1000",
                            XDG_SESSION_TYPE="wayland",
                            PYTHONPATH=os.environ.get('PYTHONPATH', flandre.MODULE_FOLDER.parent),
                            FLANDRE_CONFIG=software_config.json_text,
                            )
                   )


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    MainUI()(software_config=C.read_config_text(os.environ['FLANDRE_CONFIG']))
