一个ubuntu调整音量的脚本

公司要用的,调整声音输出通道及调整音量大小(要求超过100%)。

#!/bin/bash
option=100
name=$(pacmd list-sinks|grep name|awk -F "[<>]" 'NR==1{print $2}')
echo -e "\n"
echo '                      输入0退出脚本 '
echo '                      输入1切换声音通道1 '
echo '                      输入2切换声音通道2 '
echo '                      输入3调整声音大小 '
until [ $option -eq 0 ]
do
echo -e "\n"
read -p "请输入选项 : " option
echo 'your option is: ' $option 
echo -e "\n"
case $option in
1)
volume1=$(pacmd list-sinks|grep analog|awk 'NR==3{print $1}'|awk '{sub(/.$/,"")}1')
pacmd set-sink-port "$name $volume1"
echo '切换完成1';;
2)
volume2=$(pacmd list-sinks|grep analog|awk 'NR==4{print $1}'|awk '{sub(/.$/,"")}1')
pacmd set-sink-port "$name $volume2"
echo '切换完成2';;
3)
read -p '输入要调整的大小,比如120: ' vol
pactl set-sink-volume 0 $vol"%"
echo "已设置音量为"$vol"%";;
esac
done
exit
Last modification:June 6th, 2019 at 07:31 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment