Mine
public text v1 · immutable#!/bin/bash
PROG="mythfrontend"
#STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'`
STATUS=`pgrep ${PROG}|wc -l|awk '{print $1}'`
if [[ X${DISPLAY}X != XX ]]
then
if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ]
then
if [ $STATUS -eq 0 ]
then
( $PROG & )
else
killall $PROG
fi
fi
fi
exit 0