Sound toggle script for FreeBSD

../ r

2022-11-17

Binding your keyboard to volume control in FreeBSD is a simple matter of $ mixer vol -5 . In some cases however, the 'usual' method of toggling sound on and off requires a workaround, because muting sound through 'vol' sets it to 0 and doesn't by default restore it to the previous levels.

The following script will save the current volume levels and mute the audio. Executing the script again will restore the previous levels.

#!/bin/sh
if [ -f ~/.togglevol ]
then
         mixer `cat ~/.togglevol`
         rm ~/.togglevol
else
         mixer -s vol > ~/.togglevol
         mixer vol 0:0
 fi
mini-beastie

Source

triapul.cz