aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/RofiBeats.sh
diff options
context:
space:
mode:
authorLinxford Kwabena <linxford7@gmail.com>2024-05-12 11:06:50 +0000
committerJa.KooLit <ejhay.games@gmail.com>2024-05-12 21:46:57 +0900
commitca3a8941e7b647ed40b60c247869a4de9cae26f5 (patch)
tree99eee918e9d2e38016558ff45dded7f8141fa28a /config/hypr/UserScripts/RofiBeats.sh
parent9263e9c81aaa149437326fb36080b0e1cbb64c57 (diff)
Update RofiBeats.sh || Add support for local and online music playback
This commit introduces enhancements to the music playback script. It now allows users to choose between local and online music options. Under each category, the available songs are displayed, and the selected song is played using `mpv`. Additionally, shuffle functionality has been added to provide a randomized listening experience. The code has been refactored to include separate functions for playing local and online music, improving code organization and readability. These changes aim to provide users with a more versatile and enjoyable music playback experience.
Diffstat (limited to 'config/hypr/UserScripts/RofiBeats.sh')
-rwxr-xr-xconfig/hypr/UserScripts/RofiBeats.sh64
1 files changed, 50 insertions, 14 deletions
diff --git a/config/hypr/UserScripts/RofiBeats.sh b/config/hypr/UserScripts/RofiBeats.sh
index e3c79587..5620f666 100755
--- a/config/hypr/UserScripts/RofiBeats.sh
+++ b/config/hypr/UserScripts/RofiBeats.sh
@@ -3,11 +3,18 @@
# Directory for icons
iDIR="$HOME/.config/swaync/icons"
-# Note: You can add more options below with the following format:
-# ["TITLE"]="link"
+# Define menu options as associative arrays for local and online music
+declare -A local_music
-# Define menu options as an associative array
-declare -A menu_options=(
+# Populate the menu_options array with music files from the Music folder
+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"
["Easy Rock 96.3 FM 📻🎶"]="https://radio-stations-philippines.com/easy-rock"
["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: $@"
}
-# Main function
-main() {
- choice=$(printf "%s\n" "${!menu_options[@]}" | rofi -i -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi -p "")
+# Main function for playing local music
+play_local_music() {
+ choice=$(printf "%s\n" "${!local_music[@]}" | rofi -i -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi -p "Local Music")
if [ -z "$choice" ]; then
exit 1
fi
- link="${menu_options[$choice]}"
+ file="${local_music[$choice]}"
notification "$choice"
- # Check if the link is a playlist
- if [[ $link == *playlist* ]]; then
- mpv --shuffle --vid=no "$link"
- else
- mpv "$link"
+ # Play the selected local music file using mpv
+ mpv --shuffle --vid=no "$file"
+}
+
+# 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
+
+ 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
-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
+}
+
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage