i create this not working script,
#!/bin/bash
echo "Mic Check"
timeout 2 pacat -r ./testmic -d 2
FILENAME=./testmic
FILESIZE=$(stat -c%s "$FILENAME")
killall pacat
if (( $FILESIZE <= 100 )); then
echo "Mic Muted..."
else
echo "Mic not Muted..."
fi
my headphones have a mute button but no led to indicate this =[ im trying to use a script to alert me when the mic is open
I don't know if this is the best way to do this, but... this script creates a "testMic" file, when i press the mute button the file is created with nothing inside:
but when i not press to mute, the file is created with audio code:
i don't understand very well whats happening, but $FILESIZE aways return same value. any way to make this more effective?
tks guys
Edit1: The problem in this code is, always, if the testMic file is blank or if it has an audio code inside, the value of $FILESIZE is the same.
Edit2: I don't want to solve the problem by muting the mic in the system, I want to use the mute system from the headset itself
Edit3: I solved the problem with this code:
#!/bin/bash
echo "Mic Check"
timeout 2 pacat -r ./testmic -d 2
FILECONTENT=$(grep -L -z -e . testmic)
killall pacat
if [[ "$FILECONTENT" == "testmic" ]]; then
echo "Mic Muted."
else
echo "Mic not Muted."
fi