mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-06 18:43:08 +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=(
|
MUSIC_SERVICES=(
|
||||||
# YouTube Music specific patterns (NOT regular YouTube)
|
# YouTube Music specific patterns (NOT regular YouTube)
|
||||||
"music.youtube.com"
|
"music.youtube.com"
|
||||||
|
"youtube-music" # Electron app
|
||||||
|
"YouTube Music" # Window title
|
||||||
# Spotify
|
# Spotify
|
||||||
"spotify"
|
"spotify"
|
||||||
"Spotify"
|
"Spotify"
|
||||||
@ -69,7 +71,8 @@ MUSIC_SERVICES=(
|
|||||||
log_message() {
|
log_message() {
|
||||||
local msg
|
local msg
|
||||||
msg="$(date '+%Y-%m-%d %H:%M:%S') - $1"
|
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
|
# Check if any focus application is running
|
||||||
@ -143,10 +146,17 @@ kill_music_services() {
|
|||||||
done
|
done
|
||||||
fi
|
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
|
# Kill Spotify
|
||||||
if pgrep -x "spotify" &>/dev/null; then
|
if pgrep -x "spotify" &>/dev/null; then
|
||||||
log_message "Killing Spotify"
|
log_message "Killing Spotify"
|
||||||
pkill -x "spotify" 2>/dev/null || true
|
pkill -9 -x "spotify" 2>/dev/null || true
|
||||||
killed=true
|
killed=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -155,7 +165,7 @@ kill_music_services() {
|
|||||||
for proc in "${music_processes[@]}"; do
|
for proc in "${music_processes[@]}"; do
|
||||||
if pgrep -i -f "$proc" &>/dev/null; then
|
if pgrep -i -f "$proc" &>/dev/null; then
|
||||||
log_message "Killing $proc"
|
log_message "Killing $proc"
|
||||||
pkill -i -f "$proc" 2>/dev/null || true
|
pkill -9 -i -f "$proc" 2>/dev/null || true
|
||||||
killed=true
|
killed=true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user