aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/RofiBeats.sh
diff options
context:
space:
mode:
authorJa.KooLit <85185940+JaKooLit@users.noreply.github.com>2024-05-24 13:52:30 +0900
committerGitHub <noreply@github.com>2024-05-24 13:52:30 +0900
commit5acf937b57fd0c25baf26cae45e0f15862ab7d52 (patch)
treedbcae5ec4d6c9199dcb482f313bef2bf461edb4f /config/hypr/UserScripts/RofiBeats.sh
parent912f18dd534ea7244b7e453e65a84344b34b15b0 (diff)
parent06d66be192eeb6f844d7069d05ffc34653352791 (diff)
Merge pull request #300 from JaKooLit/development
Pre-release stage: Development to Main
Diffstat (limited to 'config/hypr/UserScripts/RofiBeats.sh')
-rwxr-xr-xconfig/hypr/UserScripts/RofiBeats.sh41
1 files changed, 30 insertions, 11 deletions
diff --git a/config/hypr/UserScripts/RofiBeats.sh b/config/hypr/UserScripts/RofiBeats.sh
index 1cf2a445..7fed687f 100755
--- a/config/hypr/UserScripts/RofiBeats.sh
+++ b/config/hypr/UserScripts/RofiBeats.sh
@@ -1,12 +1,14 @@
#!/bin/bash
+# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
+# For Rofi Beats to play online Music or Locally save media files
-# Directory music folder
+# Directory local music folder
mDIR="$HOME/Music/"
# Directory for icons
iDIR="$HOME/.config/swaync/icons"
-# Online Stations
+# Online Stations. Edit as required
declare -A online_music=(
["AfroBeatz 2024 🎧"]="https://www.youtube.com/watch?v=7uB-Eh9XVZQ"
["Lofi Girl ☕️🎶"]="https://play.streamafrica.net/lofiradio"
@@ -22,7 +24,6 @@ declare -A online_music=(
["Korean Drama OST 📻🎶"]="https://youtube.com/playlist?list=PLUge_o9AIFp4HuA-A3e3ZqENh63LuRRlQ"
)
-# Local Music
# Populate local_music array with files from music directory and subdirectories
populate_local_music() {
local_music=()
@@ -49,18 +50,33 @@ play_local_music() {
exit 1
fi
- # Find the corresponding file path based on user's choice
- for (( i=0; i<"${#filenames[@]}"; i++ )); do
+ # Find the corresponding file path based on user's choice and set that to play the song then continue on the list
+ for (( i=0; i<"${#filenames[@]}"; ++i )); do
if [ "${filenames[$i]}" = "$choice" ]; then
- file="${local_music[$i]}"
+
+ notification "$choice"
+
+ # For some reason wont start playlist at 0
+ if [[ $i -eq 0 ]]; then
+ # Play the selected local music file using mpv
+ mpv --loop-playlist --vid=no "$mDIR"
+
+ else
+ file=$i
+ # Play the selected local music file using mpv
+ mpv --playlist-start="$file" --loop-playlist --vid=no "$mDIR"
+ fi
break
fi
done
+}
- notification "$choice"
+# Main function for shuffling local music
+shuffle_local_music() {
+ notification "Shuffle local music"
- # Play the selected local music file using mpv
- mpv --shuffle --vid=no "$file"
+ # Play music in $mDIR on shuffle
+ mpv --shuffle --loop-playlist --vid=no "$mDIR"
}
# Main function for playing online music
@@ -80,10 +96,10 @@ play_online_music() {
}
# 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" "Music stopped" || {
# Prompt the user to choose between local and online music
-user_choice=$(printf "Play from Online Stations\nPlay from Music Folder" | rofi -dmenu -config ~/.config/rofi/config-rofi-Beats-menu.rasi -p "Select music source")
+user_choice=$(printf "Play from Online Stations\nPlay from Music Folder\nShuffle Play from Music Folder" | rofi -dmenu -config ~/.config/rofi/config-rofi-Beats-menu.rasi -p "Select music source")
case "$user_choice" in
"Play from Music Folder")
@@ -92,6 +108,9 @@ user_choice=$(printf "Play from Online Stations\nPlay from Music Folder" | rofi
"Play from Online Stations")
play_online_music
;;
+ "Shuffle Play from Music Folder")
+ shuffle_local_music
+ ;;
*)
echo "Invalid choice"
;;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage