Skip to content

Instantly share code, notes, and snippets.

@Javinator9889
Created May 25, 2021 16:54
Show Gist options
  • Save Javinator9889/54f9237f4daa37daf908214243f0fa36 to your computer and use it in GitHub Desktop.
Save Javinator9889/54f9237f4daa37daf908214243f0fa36 to your computer and use it in GitHub Desktop.
Simple MP3 player using "select" - won't work with files with spaces (must fix)
#!/bin/env bash
# Limpiamos el terminal
clear
# Instalación de la aplicación si no existe
if [[ ! $(command -v mpg321) ]]; then
CORRECT=1
while [[ $CORRECT -ne 0 ]]; do
read -n1 -p "La aplicación \"mpg321\" no está instalada. ¿Instalar? [Y/n] " INSTALL
echo
case $INSTALL in
Y|y)
sudo apt install -y mpg321
CORRECT=$?;;
N|n)
echo "No se instalará. Saliendo"
exit 1;;
*)
echo "Opción no reconocida '$INSTALL'"
CORRECT=1;;
esac
done
fi
MP3_FILES=$(find . -iname "*.mp3" 2> /dev/null)
MP3_FILES=$MP3_FILES" Salir"
select MP3 in $MP3_FILES; do
if [[ $MP3 = "Salir" ]]; then
break
fi
echo "Reproduciendo \"$MP3\"..."
mpg321 "$MP3" &> /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment