reckill/reckill.zsh

29 lines
957 B
Bash
Raw Normal View History

2024-12-09 13:36:41 -06:00
#!/bin/zsh
# Check for processes using the audio or video resources
echo "Checking for processes that might be recording..."
# Find processes using the audio or video resources (CoreAudio and video)
audio_processes=$(lsof | grep -E 'CoreAudio|video')
if [[ -n "$audio_processes" ]]; then
echo "Possible recording app found using audio or video resources:"
echo "$audio_processes"
# Extract only the PIDs (column 2), handling spaces correctly
pids=$(echo "$audio_processes" | awk '{print $2}' | sort | uniq)
echo $pids
# Loop through each PID and kill it
pidArray=(${(f)pids})
echo $pidArray
for pid in "${pidArray[@]}"; do
if [[ "$pid" =~ ^[0-9]+$ ]]; then # Make sure it's a valid PID (numeric)
echo "Killing process with PID: $pid"
kill -9 "$pid" # Ensure each PID is passed separately
fi
done
else
echo "No processes found using audio or video resources."
fi