diff options
| author | JaKooLit <ejhay.games@gmail.com> | 2025-03-16 20:23:22 +0900 |
|---|---|---|
| committer | JaKooLit <ejhay.games@gmail.com> | 2025-03-16 20:23:22 +0900 |
| commit | b1e7302265578fa070262f089d5751fad8dbea8c (patch) | |
| tree | 4ffc187241a04dceacb682dda655f63ba5db52e9 /config/hypr/UserScripts | |
| parent | 9718887ee05da55d78fb26e2d1a61d90a17a4965 (diff) | |
adjusted WallpaperSelect.sh & Rofi-Beats.sh to prevent killing the mpv used by mpvpaper
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/RofiBeats.sh | 37 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperSelect.sh | 7 |
2 files changed, 26 insertions, 18 deletions
diff --git a/config/hypr/UserScripts/RofiBeats.sh b/config/hypr/UserScripts/RofiBeats.sh index b134c8a2..781e9f64 100755 --- a/config/hypr/UserScripts/RofiBeats.sh +++ b/config/hypr/UserScripts/RofiBeats.sh @@ -1,6 +1,6 @@ #!/bin/bash # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## -# For Rofi Beats to play online Music or Locally save media files +# For Rofi Beats to play online Music or Locally saved media files # Variables mDIR="$HOME/Music/" @@ -41,7 +41,7 @@ populate_local_music() { # Function for displaying notifications notification() { - notify-send -u normal -i "$iDIR/music.png" " Now Playing:" " $@" + notify-send -u normal -i "$iDIR/music.png" "Now Playing:" "$@" } # Main function for playing local music @@ -60,8 +60,6 @@ play_local_music() { if [ "${filenames[$i]}" = "$choice" ]; then notification "$choice" - - # Play the selected local music file using mpv mpv --playlist-start="$i" --loop-playlist --vid=no "${local_music[@]}" break @@ -95,18 +93,30 @@ play_online_music() { mpv --shuffle --vid=no "$link" } +# Function to stop music and kill mpv processes +stop_music() { + mpv_pids=$(pgrep -x mpv) -# 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" "Music stopped" || { + if [ -n "$mpv_pids" ]; then + # Get the PID of the mpv process used by mpvpaper (using the unique argument added) + mpvpaper_pid=$(ps aux | grep -- 'unique-wallpaper-process' | grep -v 'grep' | awk '{print $2}') -# Check if rofi is already running -if pidof rofi > /dev/null; then - pkill rofi -fi + for pid in $mpv_pids; do + if ! echo "$mpvpaper_pid" | grep -q "$pid"; then + kill -9 $pid || true + fi + done + notify-send -u low -i "$iDIR/music.png" "Music stopped" || true + 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) -# Prompt the user to choose between local and online music -user_choice=$(printf "Play from Online Stations\nPlay from Music directory\nShuffle Play from Music directory" | rofi -dmenu -config $rofi_theme_1) + echo "User choice: $user_choice" case "$user_choice" in "Play from Music directory") @@ -119,7 +129,6 @@ user_choice=$(printf "Play from Online Stations\nPlay from Music directory\nShuf shuffle_local_music ;; *) - echo "Invalid choice" ;; esac -} +fi
\ No newline at end of file diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index 0816cd49..161611d8 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -46,7 +46,7 @@ rofi_override="element-icon{size:${adjusted_icon_size}%;}" # Kill existing wallpaper daemons kill_wallpaper_for_video() { killall swww - killall mpvpaper + killall mpvpaper pkill swaybg pkill hyprpaper } @@ -170,7 +170,6 @@ apply_image_wallpaper() { set_sddm_wallpaper } -# Apply Video Wallpaper apply_video_wallpaper() { local video_path="$1" @@ -181,8 +180,8 @@ apply_video_wallpaper() { fi kill_wallpaper_for_video - # Apply video wallpaper using mpvpaper - mpvpaper '*' -o "no-audio --loop" "$video_path" & + # Apply video wallpaper using mpvpaper, adding a unique argument + mpvpaper '*' -o "no-audio --loop --unique-wallpaper-process" "$video_path" & } # Main function |
