Add libnotify notification if found
If `send-notify` is recognized as valid command, the dbg_msg function will send it there instead of printing it to stdout. The urgency of the message corresponds with low/normal/critical to the debug levels info/warn/error.
This commit is contained in:
parent
467cea919c
commit
27f0988a5e
1 changed files with 18 additions and 1 deletions
17
utilities.sh
17
utilities.sh
|
@ -78,7 +78,24 @@ dbg_msg() {
|
||||||
info) display=2 ;;
|
info) display=2 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# if the user wants to be informed, send it out there
|
||||||
if (("$level" <= "$display")); then
|
if (("$level" <= "$display")); then
|
||||||
|
|
||||||
|
# send it to notification daemon if libnotify exists
|
||||||
|
if command -v notify-send >/dev/null; then
|
||||||
|
local urgency
|
||||||
|
case "$level" in
|
||||||
|
0) urgency="critical" ;;
|
||||||
|
1) urgency="normal" ;;
|
||||||
|
2 | *) urgency="low" ;;
|
||||||
|
esac
|
||||||
|
notify-send --urgency="$urgency" "$(tr '[:lower:]' '[:upper:]' <<<\["$application"])" "$@"
|
||||||
|
|
||||||
|
else
|
||||||
|
# otherwise just print it out
|
||||||
|
printf "%s: 📦 %s must be installed for this function.\n" "$2" "$1"
|
||||||
printf "%b%-15s %s \u001b[0m\n" "$color" "$(tr '[:lower:]' '[:upper:]' <<<\["$application"])" "$@"
|
printf "%b%-15s %s \u001b[0m\n" "$color" "$(tr '[:lower:]' '[:upper:]' <<<\["$application"])" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue