mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-04 11:43:03 +02:00
Fix music parallelism: add youtube-music Electron app detection and use SIGKILL
- Added 'youtube-music' and 'YouTube Music' patterns to detect Electron app - Added explicit killing of youtube-music process - Use SIGKILL (-9) to ensure apps are actually terminated - Fixed log function to not fail on permission errors
This commit is contained in:
parent
addfa1a9ae
commit
3e1b8e7d8a
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user