脚本不会重置音量,也不会退出终端

脚本不会重置音量,也不会退出终端

该脚本基本可以正常运行。

但是该脚本不会将音量重置为30%,也不会退出终端。

我究竟做错了什么?

soundfile="/usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3"
#originalVolume=$(amixer -D pulse get Master | grep -m 1 -o -E [[:digit:]]+%)
clear
amixer -D pulse sset Master 50% > /dev/null 2>&1
if [ -f "$soundfile" ];
then
     echo "Soundfile is present."
else
      
  echo "File $soundfile does NOT exist."
  echo
  echo "Program will now exit."
  exit
fi

[ -z "$2" ] && {
echo 
echo -e "   Error!! No time value given and/or message specified !!"
echo
echo -e "   Alarm Program 2018"
echo
echo -e "   alarm.sh [time value in seconds] Message in double Quotes"; 
echo -e "   alarm 5m   = 5 minute alarm"
echo -e "   alarm 5h   = 5 hour alarm"
echo -e "   alarm 5d   = 5 day alarm"
echo -e "   alarm 1.5m = 1 minute 30 seconds alarm"
echo 
echo -e "   alarm.sh 1m "\"Take bread out of oven."\""  

echo 
exit 1; }
echo  -e "\033[32;5mTIMER COUNTING DOWN to $1 \033[0m"
sleep $1
{
    for ((volume = 35; volume <= 65; volume += 2)); do
        amixer -D pulse sset Master ${volume}% > /dev/null
        sleep .5
    done
} &

cvlc --play-and-exit "$soundfile" > /dev/null 2>&1
echo $2
#set back to original volume
amixer -D pulse sset Master 30%

gxmessage -fg blue -font  'sans 20' -timeout 2 ' TIME IS UP !!'
exit

相关内容