Pages

Launching Banshee

When my Mint-based media player logs on I want Banshee to launch and start playing. For some reason the --play command line option doesn't work when Banshee starts up. So I wrote this script to launch Banshee and then issue the "play" command.
#!/bin/bash

##############################################
# Launch Banshee
##############################################

banshee &

##############################################
# Wait until Banshee appears in the
# list of running processes
##############################################

let watchdogcount=30

while :
do
 ps -A | grep -w "banshee"
 if [ $? == 0 ]
 then
  break
 fi
 echo "sleeping"
 sleep 1

 # Ensure that the script doesn't loop forever
 ((watchdogcount--))
 if [ $watchdogcount == 0 ]
 then
  echo "timeout"
  exit
 fi
done

##############################################
# Issue "play" command until Banshee's
# state is "playing"
##############################################

while :
do
 echo "checking state"
 banshee --query-current-state | grep -w "playing"
 if [ $? == 0 ]
 then
  break
 fi
 banshee --play
 sleep 1
 echo "sleeping"
done

I saved the script in my Documents folder as "banshee_play", made it executable then added it as one of my Startup Applications...