check_mp3() {

   INSTALLED=`dpkg --get-selections libxine1-ffmpeg | grep install`

   if [ -z "$INSTALLED" ]; then
     if [ -x /usr/bin/kdialog ]; then
       kdialog --msgbox "There was an error installing MP3 support. You need to install the package \"libxine1-ffmpeg\" manually." --icon amarok
     elif [ -x /usr/bin/zenity ]; then
       zenity --info --text "There was an error installing MP3 support. You need to install the package \"libxine1-ffmpeg\" manually."
     else
       Xdialog --msgbox "There was an error installing MP3 support.\nYou need to install the package \"libxine1-ffmpeg\" manually." 10 60
     fi
     exit 1
   else
     if [ -x /usr/bin/kdialog ]; then
       kdialog --msgbox "MP3 support now installed, you will need to restart Amarok." --icon amarok
     elif [ -x /usr/bin/zenity ]; then
       zenity --info --text "MP3 support now installed, you will need to restart Amarok."
     else
       Xdialog --msgbox "MP3 support now installed, you will need to restart Amarok." 5 60
     fi
     exit 0
   fi
}

INSTALLED=`dpkg --get-selections libxine1-ffmpeg | grep install`

#is available, not installed
if [ -z "$INSTALLED" ]; then
  if [ -x /usr/bin/kdesu ] && [ -x /usr/bin/adept_batch ]; then
    kdesu -d "adept_batch update --icon amarok" && kdesu -d "adept_batch install libxine1-ffmpeg --icon amarok"
  elif [ -x /usr/bin/gksudo ] && [ -x /usr/sbin/synaptic ]; then
    gksudo "apt-get update" && gksudo "echo libxine1-ffmpeg i | synaptic --set-selections --non-interactive"
  else
    xterm -e 'sudo apt-get update && sudo apt-get install libxine1-ffmpeg'
  fi
  check_mp3
fi

exit 0
