From 922626077f260922b549312d8a5553804cb91adf Mon Sep 17 00:00:00 2001 From: Daniel <48409433+darkeddie@users.noreply.github.com> Date: Mon, 20 May 2024 07:04:52 +0000 Subject: [PATCH] Make music keep playing if song chosen --- config/hypr/UserScripts/RofiBeats.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/config/hypr/UserScripts/RofiBeats.sh b/config/hypr/UserScripts/RofiBeats.sh index 5753857..04af722 100755 --- a/config/hypr/UserScripts/RofiBeats.sh +++ b/config/hypr/UserScripts/RofiBeats.sh @@ -49,18 +49,24 @@ play_local_music() { exit 1 fi - # Find the corresponding file path based on user's choice - for (( i=0; i<"${#filenames[@]}"; i++ )); do + # Find the corresponding file path based on user's choice and set that to play the song then continue on the list + for (( i=0; i<"${#filenames[@]}"; ++i )); do if [ "${filenames[$i]}" = "$choice" ]; then - file="${local_music[$i]}" + + notification "$choice" + # For some reason wont start playlist at 0 + if [[ $i -eq 0 ]]; then + # Play the selected local music file using mpv + mpv --loop-playlist --vid=no "$mDIR" + + else + file=$i + # Play the selected local music file using mpv + mpv --playlist-start="$file" --loop-playlist --vid=no "$mDIR" + fi break fi done - - notification "$choice" - - # Play the selected local music file using mpv - mpv --shuffle --vid=no "$file" } # Main function for playing online music @@ -84,7 +90,7 @@ shuffle_local_music() { notification "Shuffle local music" # Play music in $mDIR on shuffle - mpv --shuffle --vid=no "$mDIR" + mpv --shuffle --loop-playlist --vid=no "$mDIR" } # Check if an online music process is running and send a notification, otherwise run the main function