#!/bin/bash # Directory for icons iDIR="$HOME/.config/swaync/icons" # 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") menu_options["$filename"]="$file" done # Function for displaying notifications 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 "") if [ -z "$choice" ]; then exit 1 fi file="${menu_options[$choice]}" notification "$choice" # Play the selected music file using mpv mpv "$file" } # 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