[Level 3] Control Audio Device.
My laptop will always beep on while boot,
and I cannot use the command "xset -b" to turn it off.
On community friend(evereasy) told me that I can use the command "audioctl" to control it.
Then I wrote a sample script for it.
Wish this helps.
regards,
Stanley Huang
and I cannot use the command "xset -b" to turn it off.
On community friend(evereasy) told me that I can use the command "audioctl" to control it.
Then I wrote a sample script for it.
#!/usr/bin/bash
showUsage() {
cat <<EOF
Usage:
$0 device [display]
$0 device control value
Ex.
$0 $sSampleDevice
$0 $sSampleDevice beep 0
Device:
`listDevice | sed -e 's/^/ /'`
Control($sSampleDevice):
`showControl $sSampleDevice | awk '{print($2)}' | tail +1 | sed -e 's/^/ /'`
EOF
}
listDevice() {
#echo "audioctl list-devices ..."
audioctl list-devices
}
showDevice() {
#echo "audioctl show-devices ..."
sDevice=$1
audioctl show-device -v -d $sDevice
}
showControl() {
#echo "audioctl show-control ..."
sDevice=$1
audioctl show-control -v -d $sDevice
}
alias audioctl='/usr/bin/audioctl'
sSampleDevice=`listDevice | head -1`
sDevice=$1
sControl=$2
nValue=$3
if [ $# -lt 1 ]
then
showUsage
exit 1
elif [ $# -eq 1 ]
then
echo "Show device..."
showDevice $1
echo ""
echo "Show device control..."
showControl $1
elif [ $# -eq 3 ]
then
audioctl set-control -v -d $sDevice $sControl $nValue
else
showUsage
exit 1
fi
showUsage() {
cat <<EOF
$0 device [display]
$0 device control value
Ex.
$0 $sSampleDevice
$0 $sSampleDevice beep 0
Device:
`listDevice | sed -e 's/^/ /'`
Control($sSampleDevice):
`showControl $sSampleDevice | awk '{print($2)}' | tail +1 | sed -e 's/^/ /'`
EOF
}
listDevice() {
#echo "audioctl list-devices ..."
audioctl list-devices
}
showDevice() {
#echo "audioctl show-devices ..."
sDevice=$1
audioctl show-device -v -d $sDevice
}
showControl() {
#echo "audioctl show-control ..."
sDevice=$1
audioctl show-control -v -d $sDevice
}
alias audioctl='/usr/bin/audioctl'
sSampleDevice=`listDevice | head -1`
sDevice=$1
sControl=$2
nValue=$3
if [ $# -lt 1 ]
then
showUsage
exit 1
elif [ $# -eq 1 ]
then
echo "Show device..."
showDevice $1
echo ""
echo "Show device control..."
showControl $1
elif [ $# -eq 3 ]
then
audioctl set-control -v -d $sDevice $sControl $nValue
else
showUsage
exit 1
fi
Wish this helps.
regards,
Stanley Huang
Thanks for sharing this nice script ...
ReplyDelete