File yuga-mig-firstboot-kde of Package branding-Yuga

#!/bin/bash

# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Copyright 2024 Tobias Görgens

installFlatpakRepo(){
    /usr/bin/flatpak remote-add --user --if-not-exists flathub /usr/share/yuga/flathub.flatpakrepo
    if [ "$?" != 0 ] ; then
        kdialog --error "Adding Flathub Repo Failed"
        exit 1
    fi
}


waitforNet(){
    until /usr/bin/curl -s --max-time 5 https://flathub.org > /dev/null; do sleep 1; done
}

firstMSG() {
    kdialog --geometry 600x400 --title 'Welcome to Yuga Linux' \
      --yesno 'Almost done, there is one last step\n\nWe need perform some checks to make\nsure your migration has gone smoothly\n\nPlease click OK to Continue' \
      --yes-label OK \
      --no-label Exit
}

lastMSG() {
    kdialog --geometry 600x400 --msgbox 'Congratulations!\n\nYour system is ready to be used\n\nWe hope you enjoy using Yuga Linux' --title 'Welcome to Yuga Linux'
    rm ~/.config/autostart/yuga-mig-firstboot.desktop
}

detectLocale() {
    if [[ ! "${LANG}" =~ ^en_ ]]; then
        need_locale=${LANG}
    fi
}

show_progress() {
    local step="$1"
    local label="$2"

    qdbus6 $dbusRef setLabelText "$label"
    qdbus6 $dbusRef Set "" value "$step"
}


install_locale() {
    pkexec /usr/bin/yuga-set-language "${need_locale}"
    if [ "$?" != 0 ] ; then
        kdialog --error "Installing Locales Failed"
        exit 1
    fi
}

run_tasks() {
    dbusRef=$(kdialog --title "Final Setup" --geometry 600x400 --progressbar "Final Setup" 100)
    show_progress 10 "Waiting for Internet connection"
    waitforNet

    show_progress 50 "Installing Locales"
    if [[ -n "${need_locale}" ]]; then
       install_locale
    fi

    show_progress 90 "Adding Flathub"
    installFlatpakRepo

    show_progress 100 "Installation complete"
    qdbus6 $dbusRef close
}

detectLocale
firstMSG
run_tasks
lastMSG
openSUSE Build Service is sponsored by