#!/bin/sh
# needs banshee 0.10.6 or newer
#
# By Ruben "RubenV" Vermeersch
# Rewritten by Zoltán Nagy
# Speed improvements by João Vale

BANSHEE=`ps -e | grep [b]anshee | grep -v info| awk '{print $4}'`

if [ -z "$BANSHEE" ]
then
    echo "Banshee is not running"
else
    if [ "$BANSHEE" = "banshee" ]; then
        version=0
    elif [ "$BANSHEE" = "banshee-1" ]; then
        version=1
    fi

    if [ $version = 0 ]
    then
        banshee --query-status |sed  s/^//|cut -c9-
        banshee --query-title |sed  s/^//|cut -c8-
        banshee --query-artist |sed  s/^//|cut -c9-
        banshee --query-uri|sed  s/^//|cut -c6-
        banshee --query-cover-uri |sed  s/^//|cut -c11-
    elif [ $version = 1 ]
    then
		banshee-1 --query-current-state --query-title --query-artist --query-uri | sed -e 's/\(.*\): \(.*\)/\2/'
    else
        echo 0
    fi
fi
exit 0 
