#!/bin/bash STATUS="0" while [ $STATUS == "0" ] do DARKPID=`pidof darkice` function pidactive () { #sends a signal which checks if the process is active (doesn't kill anything) kill -0 $1 2> /dev/null return } if pidactive $DARKPID; then STATUS="1" else STATUS="2" fi done if [ $STATUS == "2" ]; then /usr/bin/aplay "$@" fi