diff options
| author | Donald Williams <129223418+dwilliam62@users.noreply.github.com> | 2025-06-05 08:27:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-05 08:27:52 -0400 |
| commit | a2801f2eea287107097b68695a7c5306520dce8e (patch) | |
| tree | 735636d83cb09c68c129c119537a2b4fd573b455 /config/hypr/UserScripts | |
| parent | b2d5d1a5f4acdb7354009b7c0e5df2f7e4b044ec (diff) | |
| parent | d6568b7f1b6c05abbb493af39fb12c243484da53 (diff) | |
Merge branch 'main' into feat/add-custom-hyprpicker-waybar-module
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/RofiBeats.sh | 61 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/Weather.sh | 2 |
2 files changed, 41 insertions, 22 deletions
diff --git a/config/hypr/UserScripts/RofiBeats.sh b/config/hypr/UserScripts/RofiBeats.sh index 781e9f64..1cddce09 100755 --- a/config/hypr/UserScripts/RofiBeats.sh +++ b/config/hypr/UserScripts/RofiBeats.sh @@ -58,7 +58,10 @@ play_local_music() { # 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 - + + if music_playing; then + stop_music + fi notification "$choice" mpv --playlist-start="$i" --loop-playlist --vid=no "${local_music[@]}" @@ -69,6 +72,9 @@ play_local_music() { # Main function for shuffling local music shuffle_local_music() { + if music_playing; then + stop_music + fi notification "Shuffle Play local music" # Play music in $mDIR on shuffle @@ -87,12 +93,20 @@ play_online_music() { link="${online_music[$choice]}" + if music_playing; then + stop_music + fi notification "$choice" # Play the selected online music using mpv mpv --shuffle --vid=no "$link" } +# Function to check if music is already playing +music_playing() { + pgrep -x "mpv" > /dev/null +} + # Function to stop music and kill mpv processes stop_music() { mpv_pids=$(pgrep -x mpv) @@ -110,25 +124,30 @@ stop_music() { fi } -# Check if music is already playing -if pgrep -x "mpv" > /dev/null; then - stop_music -else - user_choice=$(printf "Play from Online Stations\nPlay from Music directory\nShuffle Play from Music directory" | rofi -dmenu -config $rofi_theme_1) +user_choice=$(printf "%s\n" \ + "Play from Online Stations" \ + "Play from Music directory" \ + "Shuffle Play from Music directory" \ + "Stop RofiBeats" \ + | rofi -dmenu -config $rofi_theme_1) - echo "User choice: $user_choice" +echo "User choice: $user_choice" - case "$user_choice" in - "Play from Music directory") - play_local_music - ;; - "Play from Online Stations") - play_online_music - ;; - "Shuffle Play from Music directory") - shuffle_local_music - ;; - *) - ;; - esac -fi
\ No newline at end of file +case "$user_choice" in + "Play from Online Stations") + play_online_music + ;; + "Play from Music directory") + play_local_music + ;; + "Shuffle Play from Music directory") + shuffle_local_music + ;; + "Stop RofiBeats") + if music_playing; then + stop_music + fi + ;; + *) + ;; +esac diff --git a/config/hypr/UserScripts/Weather.sh b/config/hypr/UserScripts/Weather.sh index 0294e042..9bdaff4a 100755 --- a/config/hypr/UserScripts/Weather.sh +++ b/config/hypr/UserScripts/Weather.sh @@ -84,4 +84,4 @@ echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \ cached_weather=" $temperature \n$condition ${weather[1]}" -echo -e $cached_weather > "$HOME/.cache/.weather_cache" +echo -e $cached_weather > "$HOME/.cache/.weather_cache"
\ No newline at end of file |
