diff --git a/scripts/digital_wellbeing/music_parallelism.sh b/scripts/digital_wellbeing/music_parallelism.sh index 26b20e0..180ac7e 100755 --- a/scripts/digital_wellbeing/music_parallelism.sh +++ b/scripts/digital_wellbeing/music_parallelism.sh @@ -46,6 +46,8 @@ FOCUS_APPS=( MUSIC_SERVICES=( # YouTube Music specific patterns (NOT regular YouTube) "music.youtube.com" + "youtube-music" # Electron app + "YouTube Music" # Window title # Spotify "spotify" "Spotify" @@ -69,7 +71,8 @@ MUSIC_SERVICES=( log_message() { local msg msg="$(date '+%Y-%m-%d %H:%M:%S') - $1" - echo "$msg" | tee -a "$LOG_FILE" >&2 + echo "$msg" >&2 + echo "$msg" >>"$LOG_FILE" 2>/dev/null || true } # Check if any focus application is running @@ -143,10 +146,17 @@ kill_music_services() { done fi + # Kill YouTube Music Electron app + if pgrep -f "youtube-music" &>/dev/null; then + log_message "Killing YouTube Music app" + pkill -9 -f "youtube-music" 2>/dev/null || true + killed=true + fi + # Kill Spotify if pgrep -x "spotify" &>/dev/null; then log_message "Killing Spotify" - pkill -x "spotify" 2>/dev/null || true + pkill -9 -x "spotify" 2>/dev/null || true killed=true fi @@ -155,7 +165,7 @@ kill_music_services() { for proc in "${music_processes[@]}"; do if pgrep -i -f "$proc" &>/dev/null; then log_message "Killing $proc" - pkill -i -f "$proc" 2>/dev/null || true + pkill -9 -i -f "$proc" 2>/dev/null || true killed=true fi done