From 27b5c417ab897d546624bad45edda57b5660dc6b Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Wed, 13 Dec 2023 00:31:19 +0900 Subject: [PATCH] Improved rofi music script --- config/hypr/scripts/RofiBeats.sh | 97 +++++++++++--------------------- 1 file changed, 34 insertions(+), 63 deletions(-) diff --git a/config/hypr/scripts/RofiBeats.sh b/config/hypr/scripts/RofiBeats.sh index 3a874f5..44e4a00 100755 --- a/config/hypr/scripts/RofiBeats.sh +++ b/config/hypr/scripts/RofiBeats.sh @@ -1,73 +1,44 @@ #!/bin/bash -## Files +# Directory for icons iDIR="$HOME/.config/dunst/icons" -notification(){ - dunstify -h string:x-canonical-private-synchronous:sys-notify -u normal -i "$iDIR/music.png" "Playing now: " "$@" -} +# Note: You can add more options below with the following format: +# ["TITLE"]="link" + +# Define menu options as an associative array +declare -A menu_options=( + ["Lofi Girl ☕️🎶"]="https://play.streamafrica.net/lofiradio" + ["96.3 Easy Rock 📻🎶"]="https://radio-stations-philippines.com/easy-rock" + ["Ghibli Music 🎻🎶"]="https://youtube.com/playlist?list=PLNi74S754EXbrzw-IzVhpeAaMISNrzfUy&si=rqnXCZU5xoFhxfOl" + ["Top Youtube Music 2023 ☕️🎶"]="https://youtube.com/playlist?list=PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU&si=y7qNeEVFNgA-XxKy" + ["Chillhop ☕️🎶"]="http://stream.zeno.fm/fyn8eh3h5f8uv" + ["SmoothChill ☕️🎶"]="https://media-ssl.musicradio.com/SmoothChill" + ["Relaxing Music ☕️🎶"]="https://youtube.com/playlist?list=PLMIbmfP_9vb8BCxRoraJpoo4q1yMFg4CE" + ["Youtube Remix 📻🎶"]="https://youtube.com/playlist?list=PLeqTkIUlrZXlSNn3tcXAa-zbo95j0iN-0" + ["Korean Drama OST 📻🎶"]="https://youtube.com/playlist?list=PLUge_o9AIFp4HuA-A3e3ZqENh63LuRRlQ" +) -menu(){ -printf "1. Lofi Girl\n" -printf "2. 96.3 Easy Rock - FM Radio\n" -printf "3. Ghibli Music (Instrumental)\n" -printf "4. Top Youtube Music 2023\n" -printf "5. Chillhop\n" -printf "6. SmoothChill\n" -printf "7. Relaxing Music\n" -printf "8. Youtube Remix\n" -printf "9. Korean Drama OST" +# Function for displaying notifications +notification() { + dunstify -h string:x-canonical-private-synchronous:sys-notify -u normal -i "$iDIR/music.png" "Playing now: $@" } + +# Main function main() { -choice=$(menu | rofi -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi | cut -d. -f1) + choice=$(printf "%s\n" "${!menu_options[@]}" | rofi -dmenu -i -p "Choose a music option:") + + link="${menu_options[$choice]}" -case $choice in -1) - notification "Lofi Girl ☕️🎶"; - mpv "https://play.streamafrica.net/lofiradio" - return - ;; -2) - notification "96.3 Easy Rock 📻🎶"; - mpv "https://radio-stations-philippines.com/easy-rock" - return - ;; -3) - notification "Ghibli Music 🎻🎶"; - mpv --shuffle --vid=no "https://youtube.com/playlist?list=PLNi74S754EXbrzw-IzVhpeAaMISNrzfUy&si=rqnXCZU5xoFhxfOl" - return - ;; -4) - notification "Top Youtube Music 2023 ☕️🎶"; - mpv --shuffle --vid=no "https://youtube.com/playlist?list=PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU&si=y7qNeEVFNgA-XxKy" - return - ;; -5) - notification "Chillhop ☕️🎶"; - mpv "http://stream.zeno.fm/fyn8eh3h5f8uv" - return - ;; -6) - notification "SmoothChill ☕️🎶"; - mpv "https://media-ssl.musicradio.com/SmoothChill" - return - ;; -7) - notification "Relaxing Music ☕️🎶"; - mpv --shuffle --vid=no "https://youtube.com/playlist?list=PLMIbmfP_9vb8BCxRoraJpoo4q1yMFg4CE" - return - ;; -8) - notification "Youtube Remix 📻🎶"; - mpv --shuffle --vid=no "https://youtube.com/playlist?list=PLeqTkIUlrZXlSNn3tcXAa-zbo95j0iN-0" - return - ;; -9) - notification "Korean Drama OST 📻🎶"; - mpv --shuffle --vid=no "https://youtube.com/playlist?list=PLUge_o9AIFp4HuA-A3e3ZqENh63LuRRlQ" - return - ;; -esac + notification "$choice" + + # Check if the link is a playlist + if [[ $link == *playlist* ]]; then + mpv --shuffle --vid=no "$link" + else + mpv "$link" + fi } -pkill -f http && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/music.png" "Online Music stopped" || main +# Check if an online music process is running and send a notification, otherwise run the main function +pkill -f http && dunstify -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/music.png" "Online Music stopped" || main