update music script

This commit is contained in:
The-Repo-Club 2023-08-05 23:58:07 +01:00
parent 0804da548a
commit 7688e1732e
No known key found for this signature in database
GPG Key ID: E30EC2FBFB05C44F

View File

@ -12,7 +12,7 @@
# Created:
# Wed 10 March 2021, 12:34:47 PM [GMT]
# Modified:
# Sat 05 August 2023, 11:32:26 PM [GMT+1]
# Sat 05 August 2023, 11:57:57 PM [GMT+1]
#
# Description:
# <Todo>
@ -22,8 +22,9 @@
MUSICPLAYER="mplayer"
CURRENT_SONG=$(lsof -c "$MUSICPLAYER" | grep -F ".mp3" | awk -F"/" '{ print $NF; }' | cut -d'.' -f1)
PLAYING_MSG="Currently Playing :: ${CURRENT_SONG}"
MUSICDIR=$HOME/Music
for Song in "$HOME/Music/"*; do
for Song in "$MUSICDIR/"*; do
if [ -f "$Song" ]; then
Name=${Song##*/}
case $Name in
@ -43,9 +44,14 @@ ret=$?
if [[ $ret -eq 0 ]]; then
case $CHOICE in
*.mp3 | *.flac | *.wav | *.ogg)
folder=$HOME/Music
pkill "$MUSICPLAYER"
$MUSICPLAYER "$folder/$CHOICE" &
if pgrep -f "$MUSICPLAYER" >/dev/null; then
killall -9 "$MUSICPLAYER"
fi
if [[ $MUSICPLAYER == "mplayer" ]]; then
$MUSICPLAYER -ao alsa "$MUSICDIR/$CHOICE" >> /dev/null &
else
$MUSICPLAYER "$MUSICDIR/$CHOICE" &
fi
;;
*)
echo "Program terminated." && exit
@ -53,6 +59,6 @@ if [[ $ret -eq 0 ]]; then
esac
elif [[ $ret -gt 1 ]]; then
if [[ $ret -eq 10 ]]; then
pkill "$MUSICPLAYER"
killall -9 "$MUSICPLAYER"
fi
fi