@ -3,18 +3,20 @@
# Directory for icons
# Directory for icons
iDIR = " $HOME /.config/swaync/icons "
iDIR = " $HOME /.config/swaync/icons "
# Define menu options as associative arrays for local and online music
declare -A local_music
# Directory music folder
# Directory music folder
mDIR = " $HOME /Music/* "
mDIR = " $HOME /Music/* "
# Local Music
# Populate the menu_options array with music files from the Music folder with specified extensions
declare -A local_music
# Populate the menu_options array with music files from the Music folder
for file in $mDIR ; do
for file in $mDIR ; do
filename = $( basename " $file " )
if [ -f " $file " ] ; then
local_music[ " $filename " ] = " $file "
filename = $( basename " $file " )
local_music[ " $filename " ] = " $file "
fi
done
done
# Online Stations
declare -A online_music = (
declare -A online_music = (
[ "AfroBeatz 2024 🎧" ] = "https://www.youtube.com/watch?v=7uB-Eh9XVZQ"
[ "AfroBeatz 2024 🎧" ] = "https://www.youtube.com/watch?v=7uB-Eh9XVZQ"
[ "Lofi Girl ☕️ 🎶" ] = "https://play.streamafrica.net/lofiradio"
[ "Lofi Girl ☕️ 🎶" ] = "https://play.streamafrica.net/lofiradio"
@ -37,24 +39,37 @@ notification() {
# Main function for playing local music
# Main function for playing local music
play_local_music( ) {
play_local_music( ) {
# Prompt the user to select a song
# Prompt user to select play mode
choic e= $( printf "%s\n" " ${ !local_music[@] } " | rofi -i -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi -p "Local Music " )
mod e= $( printf "Play in order\nShuffle" | rofi -dmenu -p "Select play mode " )
if [ -z " $choic e " ] ; then
if [ -z " $mod e " ] ; then
exit 1
exit 1
fi
fi
file = " ${ local_music [ $choice ] } "
case " $mode " in
"Play in order" )
notification " $choice "
# Play in order
for choice in " ${ !local_music[@] } " ; do
# Play the selected local music file using mpv and shuffle the rest
file = " ${ local_music [ $choice ] } "
mpv --shuffle --vid= no " $file " && \
notification " $choice "
for file in $mDIR ; do
mpv --vid= no " $file "
if [ " $file " != " ${ local_music [ $choice ] } " ] ; then
done
mpv --shuffle --vid= no " $file "
; ;
fi
"Shuffle" )
done
# Shuffle the keys of local_music array
shuffled_keys = ( $( printf "%s\n" " ${ !local_music[@] } " | shuf) )
# Play shuffled
for choice in " ${ shuffled_keys [@] } " ; do
file = " ${ local_music [ $choice ] } "
notification " $choice "
mpv --vid= no " $file "
done
; ;
*)
echo "Invalid choice"
; ;
esac
}
}
# Main function for playing online music
# Main function for playing online music
@ -75,15 +90,14 @@ play_online_music() {
# Check if an online music process is running and send a notification, otherwise run the main function
# 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 " "Online Music stopped" || {
pkill mpv && notify-send -u low -i " $iDIR /music.png " "Online Music stopped" || {
# Prompt the user to choose between local and online music
# Prompt the user to choose between local and online music
user_choice = $( printf "Play from Music Folder\nPlay from Online Stations" | rofi -dmenu -config ~/.config/rofi/config-rofi-Beats-menu.rasi -p "Select music source" )
user_choice = $( printf "Play from Music Folder\nOnline Streaming" | rofi -dmenu -p "Select music source" )
case " $user_choice " in
case " $user_choice " in
"Play from Music Folder" )
"Play from Music Folder" )
play_local_music
play_local_music
; ;
; ;
"Play from Online Stations " )
"Online Streaming " )
play_online_music
play_online_music
; ;
; ;
*)
*)
@ -91,4 +105,3 @@ pkill mpv && notify-send -u low -i "$iDIR/music.png" "Online Music stopped" || {
; ;
; ;
esac
esac
}
}