From 7688e1732e91713084df574b45d5f2cefd3e31a7 Mon Sep 17 00:00:00 2001 From: The-Repo-Club Date: Sat, 5 Aug 2023 23:58:07 +0100 Subject: [PATCH] update music script --- rofi/.local/bin/rofi/music | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rofi/.local/bin/rofi/music b/rofi/.local/bin/rofi/music index 823ec3853..1e1bd023d 100755 --- a/rofi/.local/bin/rofi/music +++ b/rofi/.local/bin/rofi/music @@ -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: # @@ -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 \ No newline at end of file