diff options
| -rwxr-xr-x | play | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -7,17 +7,39 @@ # set the exit code right for quitting # echo "q quit 255" >> ~/.mpv/input.conf -if [ $1 = "-y" ] || [ $1 = "y" ] || [ $1 = "Y" ] || [ $1 = "-Y" ]; then + +if [ "$1" = "-y" ] || [ "$1" = "y" ] || [ "$1" = "Y" ] || [ "$1" = "-Y" ]; then verify="yes" shift else verify=0 fi +player[0]=$(command -v mpv) #media player of choice +player[1]=$(command -v mplayer) +player[2]=$(command -v vlc) #you shouldn't use vlc + +for i in "${player[@]}"; do + if [ ! $i = "" ]; then + player=$i + break + fi +done + +if [ ! $player ]; then + echo "No media player found. Please edit this script manually. I recommend the mpv. http://mpv.io" + exit 1 +fi + file="$@" if [ ! -d $ARCHIV ]; then echo "Note: Variable \$ARCHIV couldn't be found. It will play the file fine, but you should consider to organize your collection." + read -p "You can export it temporarily. If you do, just type the path to the folder (without the trailing slash!), if you don't, leave it empty. " path + if [ $path ] && [ -d $path ] && [ -w $path ]; then + export ARCHIV=$path + echo "Roger that!" + fi fi if [ -d /tmp ] && [ -w /tmp ]; then @@ -34,15 +56,13 @@ else fi echo -n "Preparing the awesome! Starting playback in.." -echo -n " 3" -sleep 1 echo -n " 2" sleep 1 echo -n " 1" sleep 1 echo " Start!" -mpv $tmp/"$file" +$player $tmp/"$file" if [ $? -eq 0 ]; then if [ -d $ARCHIV ] && [ -w $ARCHIV ]; then echo "Finished $file succesfull." |
