#!/usr/bin/env bash

# Sisyphus-GUI is a PyQt frontend for Sisyphus
# Main Author : Ghiunhan Mamut @ Redcore Linux Project

if [[ -f /lib/gentoo/functions.sh ]] ; then
        source /lib/gentoo/functions.sh
else
        echo "Cannot import Gentoo functions, I will abort now!"
        exit 1
fi

checkifroot() {
	if [[ "$(whoami)" != root ]] ; then
		eerror "I won't do that, unless you're root!"
		exit 1
	fi
}


main() {
	if checkifroot; then
		pushd /usr/share/sisyphus > /dev/null 2>&1
		if [ -e sisyphus-qt6.py ]; then
			tmux new-session -d -s sisyphus 'python3 sisyphus-qt6.py'
		elif [ -e sisyphus-qt5.py ]; then
			tmux new-session -d -s sisyphus 'python3 sisyphus-qt5.py'
		else
			eerror "Cannot find a PyQt application to execute!"
		fi
		popd > /dev/null 2>&1
	fi
}

main