#!/bin/bash
################################################################################
# Fichier : mp3term.sh
# Auteur  : Sebastien Beaugrand
# Date    : 12/12/2008
# Url     : http://www.chez.com/beaugrand/
################################################################################

status=`xmms-shell -e status 2>&1 | head -n 1 | cut -c-19`
if [ "$status" = "XMMS is not running" ]; then
  echo "starting XMMS..."
  soundwrapper xmms&
fi

dialog()
{
  if [ $local = o ]; then
    clear
    mp3rand.sh -i
    echo -n "? (O/n) "
    read ret
  else
    mp3xterm.sh
    ret=`cat /tmp/mp3xterm.tmp`
  fi
  if [ -z "$ret" ]; then
    ret=o
  fi
}

if [ -n "$1" ] && [ "$1" = "-x" ]; then
  local=n
else
  local=o
fi

dialog
while [ "$ret" = n ]; do
  mp3rand.sh > /dev/null
  dialog
done

status=`xmms-shell -e status 2>/dev/null | head -n 1 | cut -c-7`
if [ "$status" != "Playing" ]; then
  xmms-shell -e play > /dev/null
fi

# Fin du fichier mp3term.sh