@ -3,11 +3,18 @@
# Directory for icons
# Directory for icons
iDIR = " $HOME /.config/swaync/icons "
iDIR = " $HOME /.config/swaync/icons "
# Note: You can add more options below with the following format:
# Define menu options as associative arrays for local and online music
# ["TITLE"]="link"
declare -A local_music
# Define menu options as an associative array
# Populate the menu_options array with music files from the Music folder
declare -A menu_options = (
for file in ~/Music/*.mp3; do
filename = $( basename " $file " )
local_music[ " $filename " ] = " $file "
done
declare -A online_music = (
[ "AfroBeatz 2024 🎧" ] = "https://www.youtube.com/watch?v=7uB-Eh9XVZQ"
[ "Lofi Girl ☕️ 🎶" ] = "https://play.streamafrica.net/lofiradio"
[ "Lofi Girl ☕️ 🎶" ] = "https://play.streamafrica.net/lofiradio"
[ "Easy Rock 96.3 FM 📻🎶" ] = "https://radio-stations-philippines.com/easy-rock"
[ "Easy Rock 96.3 FM 📻🎶" ] = "https://radio-stations-philippines.com/easy-rock"
[ "Wish 107.5 FM 📻🎶" ] = "https://radio-stations-philippines.com/dwnu-1075-wish"
[ "Wish 107.5 FM 📻🎶" ] = "https://radio-stations-philippines.com/dwnu-1075-wish"
@ -26,25 +33,54 @@ notification() {
notify-send -u normal -i " $iDIR /music.png " " Playing now: $@ "
notify-send -u normal -i " $iDIR /music.png " " Playing now: $@ "
}
}
# Main function
# Main function for playing local music
main ( ) {
play_local_music ( ) {
choice = $( printf "%s\n" " ${ !menu_options [@] } " | rofi -i -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi -p "" )
choice = $( printf "%s\n" " ${ !local_music [@] } " | rofi -i -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi -p "Local Music " )
if [ -z " $choice " ] ; then
if [ -z " $choice " ] ; then
exit 1
exit 1
fi
fi
link = " ${ menu_options [ $choice ] } "
file = " ${ local_music [ $choice ] } "
notification " $choice "
notification " $choice "
# Check if the link is a playlist
# Play the selected local music file using mpv
if [ [ $link = = *playlist* ] ] ; then
mpv --shuffle --vid= no " $file "
mpv --shuffle --vid= no " $link "
}
else
mpv " $link "
# Main function for playing online music
play_online_music( ) {
choice = $( printf "%s\n" " ${ !online_music[@] } " | rofi -i -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi -p "Online Music" )
if [ -z " $choice " ] ; then
exit 1
fi
fi
link = " ${ online_music [ $choice ] } "
notification " $choice "
# Play the selected online music using mpv
mpv --shuffle --vid= no " $link "
}
}
# 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" || main
pkill mpv && notify-send -u low -i " $iDIR /music.png " "Online Music stopped" || {
# Prompt the user to choose between local and online music
user_choice = $( printf "Play from Music Folder\nOnline Streaming" | rofi -dmenu -p "Select music source" )
case " $user_choice " in
"Play from Music Folder" )
play_local_music
; ;
"Online Streaming" )
play_online_music
; ;
*)
echo "Invalid choice"
; ;
esac
}