#! /bin/bash

# Copyright (C) 2005, Christopher S. Swingley and licensed under the terms of
# the GNU General Public License version 2.0
#
# Updated and improved by Reid Rivenburgh, August 2006
#   added "Play it?" section

command=`ps auxw | grep 'mplayer' | grep 'joystick' | grep -v grep | awk '{print $2;}' | head -1 | sed "s/\(.*\)/\/proc\/\1\/cmdline/" | xargs cat | tr '\000' ' ' | sed 's/!/%21/g' | sed 's/.*\(mms.*\)/mplayer -ao oss -cache 128 \"\1\"/'`

if [ -n "$command" ]; then
  echo $command
  echo -n "Play it? "
  read answer
  if [ $answer = 'y' ]; then
	exec $command
  fi
fi
