Browse Source

Update RofiBeats.sh

adjusted a bit... made another rofi-beats menu
pull/260/head
Ja.KooLit 2 years ago committed by GitHub
parent
commit
41cd75a68f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 38
      config/hypr/UserScripts/RofiBeats.sh

38
config/hypr/UserScripts/RofiBeats.sh

@ -3,18 +3,18 @@
# 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 # Directory music folder
declare -A local_music mDIR="$HOME/Music/*"
# Populate the menu_options array with music files from the Music folder with specified extensions # Local Music
for file in ~/Music/*.{mp3,ogg,wav,flac,m4a,wma,mp4}; do declare -A local_music
if [ -f "$file" ]; then # Populate the menu_options array with music files from the Music folder
filename=$(basename "$file") for file in $mDIR; do
local_music["$filename"]="$file" filename=$(basename "$file")
fi local_music["$filename"]="$file"
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"
@ -32,11 +32,12 @@ declare -A online_music=(
# Function for displaying notifications # Function for displaying notifications
notification() { notification() {
notify-send -u normal -i "$iDIR/music.png" "Playing now: $@" notify-send -u normal -i "$iDIR/music.png" "Playing: $@"
} }
# 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
choice=$(printf "%s\n" "${!local_music[@]}" | rofi -i -dmenu -config ~/.config/rofi/config-rofi-Beats.rasi -p "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 if [ -z "$choice" ]; then
@ -46,9 +47,14 @@ play_local_music() {
file="${local_music[$choice]}" file="${local_music[$choice]}"
notification "$choice" notification "$choice"
# Play the selected local music file using mpv # Play the selected local music file using mpv and shuffle the rest
mpv --shuffle --vid=no "$file" mpv --shuffle --vid=no "$file" && \
for file in $mDIR; do
if [ "$file" != "${local_music[$choice]}" ]; then
mpv --shuffle --vid=no "$file"
fi
done
} }
# Main function for playing online music # Main function for playing online music
@ -69,14 +75,15 @@ 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\nOnline Streaming" | rofi -dmenu -p "Select music source") 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")
case "$user_choice" in case "$user_choice" in
"Play from Music Folder") "Play from Music Folder")
play_local_music play_local_music
;; ;;
"Online Streaming") "Play from Online Stations")
play_online_music play_online_music
;; ;;
*) *)
@ -84,3 +91,4 @@ pkill mpv && notify-send -u low -i "$iDIR/music.png" "Online Music stopped" || {
;; ;;
esac esac
} }

Loading…
Cancel
Save