Script to fix audio level
Use $(...) style command substitution instead of the deprecated `...` style. And double-quote variables if they might contain spaces. So instead of this:


usage="Usage: `basename $0` [-v VOL] "



Write like this:

usage="Usage: $(basename "$0") [-v VOL] "




Testing with [ ... ] is deprecated in favor of the more modern and powerful [[ ... ]]. So instead of this:


if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then 



Write like this:

if [[ $1 = -h || $1 = --help ]]; then 


This is equivalent, but notice that it's shorter, and in this form there is no need for those double-quotes. (Strictly speaking, in [ ... ] there was no need to double-quote "-h" and "--help", only "$1", the variable).



But in any case, why not move the handling of -h and --help together with the other options of the script?

while [[ $# -gt 0 ]]; do
    case "$1" in
        -h|--help)
            echo $usage
            echo "  -h, --help  for help"
            exit;;
        -v)
            shift
            [[ $# -gt 0 ]] &amp;&amp; VOL="$1";;
        -*)
            echo "Option not supported: $1" &gt;&amp;2
            echo $usage &gt;&amp;2
            exit 1;;
        *) break;;
    esac
    shift
done


This way it's simpler, and now you can use -h and --help anywhere on the command line, not only as the first argument.



About this bit:


[ -z "$(pidof -x gfaaudioloop)" ] || killall gfaaudioloop



I don't have the pidof command so I can't really test it, but in general it doesn't sound good to put the output of a program into a string just to check with -z if it's empty. Usually there is a more direct way, using the exit code of the program. Here's an example that should come quite close to what you want:

ps xa | grep -q gfaaudioloop &amp;&amp; killall gfaaudioloop




Having the exit at the end of a script makes is exit with success. Without it, the exit code of the script will be that of the last command executed. If you correctly check for and handle the exit code of all commands, then you don't need to explicitly exit. Let the script exit normally, using the exit code of the last command executed.