#!/usr/bin/sh

#*********************************************************************************************************
#*   __     __               __     ______                __   __                      _______ _______   *
#*  |  |--.|  |.---.-..----.|  |--.|   __ \.---.-..-----.|  |_|  |--..-----..----.    |       |     __|  *
#*  |  _  ||  ||  _  ||  __||    < |    __/|  _  ||     ||   _|     ||  -__||   _|    |   -   |__     |  *
#*  |_____||__||___._||____||__|__||___|   |___._||__|__||____|__|__||_____||__|      |_______|_______|  *
#* http://www.blackpantheros.eu | http://www.blackpanther.hu - kbarcza[]blackpanther.hu * Charles Barcza *
#*************************************************************************************(c)2002-2021********
# written by Charles K Barcza 
# blackPanther OS * www.bkackpanther.hu

 . /etc/bubblemsg.conf

case $LANG in
    hu*)
	on_os="blackPanther OS buborék üzenetek beállítása"
	pl_sel="Kérem válasszon a lisából ..."
	integon="KDE integráció (no/yes/auto)"
	kcheckon="KDE felismerés (no/yes/auto)"
	notifysound="Hang értesítéskor (yes/no)"
	deflock="A zárolási fájl "
	donemsg="A művelet sikeresen befejeződött..."
	quit="Kilépés, nem tesz semmit"
	lockfilemsg="Adja meg a zárolási fájl helyét és a fájl nevét. A mezőben az aktuális értéket látja"
	selectmsg="Válassza ki az új beállítási értéket."
	akt="Most:"
    ;;
    *)
	on_os="blackPanther OS bubble messages settings"
	pl_sel="Please select action ..."
	integon="KDE integration (no/yes/auto)"
	kcheckon="KDE detect (no/yes/auto)"
	notifysound="Notifysound (yes/no)"
	deflock="The lock file "
	donemsg="The action succesful..."
	quit="Exit, none action.."
	intstat="Enable"
	lockfilemsg="Please enter the lockfile path and name. The default value now showed."
	selectmsg="Please select the new set value."
	akt="Now:"
    ;;
esac

test /etc/blackPanther-release || exit
echo "
	BubbleConf starting under $(cat /etc/blackPanther-release| sed -e 's|release |v|' -e 's|for.*||')...
     "
#set -x
intset() {
	value=`pydialog --combobox "$selectmsg [$akt:$KDEINTEGRATION]" auto yes no` 
	if [[ -n $value ]];then
	perl -pi -e "s|KDEINTEGRATION=.*|KDEINTEGRATION=\"$value\"|" /etc/bubblemsg.conf
	else
	pydialog --error "Invalid value, exit"
	fi
}

chkset() {
	value=`pydialog --combobox "$selectmsg [$akt:$KDECHECK]" auto yes no` 
	if [[ -n $value ]];then
	perl -pi -e "s|KDECHECK=.*|KDECHECK=\"$value\"|" /etc/bubblemsg.conf
	else
	pydialog --error "Invalid value, exit"
	fi
}

soundset() {
	value=`pydialog --combobox "$selectmsg [$akt:$NOTIFYSOUND]" yes no` 
	if [[ -n $value ]];then
	perl -pi -e "s|NOTIFYSOUND=.*|NOTIFYSOUND=\"$value\"|" /etc/bubblemsg.conf
	else
	pydialog --error "Invalid value, exit"
	fi
}

if [ "$1" = "intset" ]&&[ $UID = 0 ];then
    intset
elif [ "$1" = "chkset" ]&&[ $UID = 0 ];then
    chkset
elif [ "$1" = "soundset" ]&&[ $UID = 0 ];then
    soundset
else
first=`pydialog --title "Bubble-Admin" --icon "blackPanther-dark" \
	--menu "<div align=left><img src='/usr/share/icons/blackPanther-dark.png'><b><i>$on_os</b></i><br></div>\
	<div align=left><small><i>$pl_sel</i></div></small>" \
	1 "$integon [$akt:$KDEINTEGRATION]" 2 "$kcheckon [$akt:$KDECHECK]" 3 "$notifysound [$akt:$NOTIFYSOUND]" 4 "$deflock [$akt:$LOCKFILE]" 5 "$quit"`

#echo "select: $first"
 if [ "$first" = "" ];then
    echo "	No selected"
 elif [ "$first" = "1" ];then
    echo "	Set KDE integration.. "
    kdesu bubbleconf intset
    pydialog --msgbox "$donemsg"
 elif [ "$first" = "2" ];then
    echo "	Set KDE detect.."
    kdesu bubbleconf chkset
    pydialog --msgbox "$donemsg"
 elif [ "$first" = "3" ];then
    echo "	Set notifysoundt.."
    kdesu bubbleconf soundset
    pydialog --msgbox "$donemsg"
 elif [ "$first" = "4" ];then
    echo "	Set lockfile... "
    input=`pydialog --inputbox "$lockfilemsg" /var/tmp/.kintegration.lock`
    echo "$input"
    if [ ! -n "$input" ];then
	pydialog --error "Invalid value, lockfile or path! No changed default lockfile."
     else
        pydialog --msgbox "Set now: $input"
    fi
 elif [ "$first" = "5" ];then
    echo "	Exit.."
    exit
 fi

fi
