diff --git a/jobhelper.sh b/jobhelper.sh index 02519c458938d0e9be33385cf8954192f8930c86..d2c247c4fecff8aa2580451c5aeac766ecdbee89 100755 --- a/jobhelper.sh +++ b/jobhelper.sh @@ -434,18 +434,21 @@ function j_notify(){ local _body="$( date +%H:%M:%S ) $2" local _rc="$3" - local _urgency="normal" - - if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then - if [ -n "$_rc" ]; then - if [ "$_rc" = "0" ]; then - _summary="OK: ${_summary}" - else - _summary="ERROR: ${_summary}" - _urgency="critical" + if which notify-send >/dev/null 2>&1; then + if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then + + local _urgency="normal" + if [ -n "$_rc" ]; then + if [ "$_rc" = "0" ]; then + _summary="OK: ${_summary}" + else + _summary="ERROR: ${_summary}" + _urgency="critical" + fi fi + + su "$SUDO_USER" -c "notify-send --urgency=${_urgency} '${_summary}' '${_body}'" fi - su "$SUDO_USER" -c "notify-send --urgency=${_urgency} '${_summary}' '${_body}'" fi }