From 5f8eeeb4419fb18acc02b9bf84d36caa94844aa8 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Mon, 20 May 2024 17:17:33 +0900 Subject: [PATCH] to resolve conflict --- config/hypr/UserScripts/RofiBeats.sh | 37 ++++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/config/hypr/UserScripts/RofiBeats.sh b/config/hypr/UserScripts/RofiBeats.sh index 5349930..04af722 100755 --- a/config/hypr/UserScripts/RofiBeats.sh +++ b/config/hypr/UserScripts/RofiBeats.sh @@ -1,14 +1,12 @@ #!/bin/bash -# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## -# This script Rofi Beats (Super Shift M) -# Directory music folder for Local Music +# Directory music folder mDIR="$HOME/Music/" # Directory for icons iDIR="$HOME/.config/swaync/icons" -# Online Stations. Edit as required / want here +# Online Stations declare -A online_music=( ["AfroBeatz 2024 🎧"]="https://www.youtube.com/watch?v=7uB-Eh9XVZQ" ["Lofi Girl ☕️🎶"]="https://play.streamafrica.net/lofiradio" @@ -24,6 +22,7 @@ declare -A online_music=( ["Korean Drama OST 📻🎶"]="https://youtube.com/playlist?list=PLUge_o9AIFp4HuA-A3e3ZqENh63LuRRlQ" ) +# Local Music # Populate local_music array with files from music directory and subdirectories populate_local_music() { local_music=() @@ -50,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 --vid=no "$file" } # Main function for playing online music @@ -82,17 +87,17 @@ play_online_music() { # Main function for shuffling local music shuffle_local_music() { - notification "Shuffle Play 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 pkill mpv && notify-send -u low -i "$iDIR/music.png" "Music stopped" || { # Prompt the user to choose between local and online music -user_choice=$(printf "Play from Online Stations\nPlay from Music Folder\nShuffle Play from Music Folder" | rofi -dmenu -config ~/.config/rofi/config-rofi-Beats-menu.rasi -p "Select music source") +user_choice=$(printf "Play from Online Stations\nPlay from Music Folder\nShuffle from Music Folder" | rofi -dmenu -config ~/.config/rofi/config-rofi-Beats-menu.rasi -p "Select music source") case "$user_choice" in "Play from Music Folder") @@ -101,7 +106,7 @@ user_choice=$(printf "Play from Online Stations\nPlay from Music Folder\nShuffle "Play from Online Stations") play_online_music ;; - "Shuffle Play from Music Folder") + "Shuffle from Music Folder") shuffle_local_music ;; *)