#!/bin/sh
set -e
search(){
music=$(mpc playlist --format '%artist% : %title%' | sed '/^ : $/d' | wdmenu)
if [ "$music" == "" ]
then
exit 1
fi
artist=$(echo "$music" | perl -pe 's/(.*) : (.*)/\1/')
title=$(echo "$music" | perl -pe 's/(.*) : (.*)/\2/')
mpc --quiet searchplay artist "$artist" title "$title"
}
delete(){
current=~/Música/"$(mpc current -f %file%)"
answer=$(echo -e "nothing\n$current" | wdmenu -p"delete?" )
if [ "$answer" == "$current" ]
trash "$answer"
mpc --quiet next
mpc --quiet update
usage(){
echo "Commands: "
echo " $0 search -- searches the current playlist for songs and plays it"
echo " $0 delete -- prompts to delete the current song"
if [ "$1" == "delete" ]
delete
elif [ "$1" == "search" ]
search
else
usage