Add fix_mic_volume.sh
This commit is contained in:
27
fix_mic_volume.sh
Normal file
27
fix_mic_volume.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
VOLUME_LEVEL=56000
|
||||
SOURCE_NAME="alsa_input.usb-Samson_Technologies_Samson_Meteor_Mic-00.analog-stereo"
|
||||
|
||||
# Get the current source index by its name
|
||||
get_source_index_by_name() {
|
||||
pactl list sources short | grep "$SOURCE_NAME" | cut -f1
|
||||
}
|
||||
|
||||
# Adjust microphone volume
|
||||
adjust_volume() {
|
||||
pactl set-source-volume "$SOURCE_NAME" $VOLUME_LEVEL
|
||||
}
|
||||
|
||||
# Initially adjust
|
||||
adjust_volume
|
||||
|
||||
# Get the current source index for the given name
|
||||
SOURCE_INDEX=$(get_source_index_by_name)
|
||||
|
||||
# Listen for volume changes and adjust if needed
|
||||
pactl subscribe | grep --line-buffered "source #$SOURCE_INDEX" | while read -r line ; do
|
||||
if echo "$line" | grep -q "Event 'change' on source #$SOURCE_INDEX"; then
|
||||
adjust_volume
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user