#!/bin/bash LINK=`cat $1` function cleanup { #Cleanup on entry and exit to make sure nothing died.. sleep 1 killall -9 xmessage #kill -9 `ps ax | grep xmessage | grep -v grep | awk '{ print $1}'` #Make sure we are cleaned up. sleep 1 killall -9 mplayer #kill -9 `ps ax | grep mplayer | grep -v grep | awk '{ print $1}'` sleep 1 #kill -9 `ps ax | grep python | grep -v grep | awk '{ print $1}'` killall -9 python } function message { xmessage -buttons "Cancel Loading Video.." "Loading YouTube Video. This may take a few seconds... This message will automatically close. Thanks to mozzwald for this. http://www.mozzwald.com/node/29 Loading: $LINK " cleanup & } cleanup message & mplayer -zoom -ao oss -framedrop -vfm ffmpeg `youtube-dl -m -g $LINK` cleanup