From b3b2551ad4c803b01ed2daf027b74506abd377c3 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Wed, 21 Jun 2023 17:02:50 +0200
Subject: [PATCH] check existence of notify-send

---
 jobhelper.sh | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/jobhelper.sh b/jobhelper.sh
index 02519c4..d2c247c 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
 }
 
-- 
GitLab