From ea0984818d6193e86a90e5f5a998163fc6b869af Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Thu, 5 Sep 2019 19:04:22 -0400 Subject: [PATCH 1/2] Override notification urgency --- README.rst | 11 +++++++++++ auto-notify.plugin.zsh | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index e5dad79..ce7c081 100644 --- a/README.rst +++ b/README.rst @@ -121,6 +121,17 @@ NOTE: This configuration option currently only works for Linux. # Set notification expiry to 10 seconds export AUTO_NOTIFY_EXPIRE_TIME=10000 + +**Notification Urgency Level** + +By default non zero exit codes lead to critical notifications. +On some systems (KDE) critical notifications will never expire. +You can override notification urgency by setting the environment variable ``"AUTO_NOTIFY_URGENCY"`` to ``"low"``, ``"normal"``, or ``"critical``. +NOTE: This configuration option currently only works for Linux. + +:: + # Force all notifications to have normal urgency + export AUTO_NOTIFY_URGENCY="normal" **Ignored Commands** diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index 5ed5c95..63d8f27 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -9,6 +9,9 @@ export AUTO_NOTIFY_IGNORE=( "vim" "nvim" "less" "more" "man" "tig" "watch" "git commit" "top" "htop" "ssh" "nano" ) +# Override notification urgency +# export AUTO_NOTIFY_URGENCY="normal" + function _auto_notify_format() { local MESSAGE="$1" local command="$2" @@ -37,8 +40,12 @@ function _auto_notify_message() { if [[ "$platform" == "Linux" ]]; then local urgency="normal" - if [[ "$exit_code" != "0" ]]; then - urgency="critical" + if [[ -z $AUTO_NOTIFY_URGENCY ]]; then + if [[ "$exit_code" != "0" ]]; then + urgency="critical" + fi + else + urgency=$AUTO_NOTIFY_URGENCY fi notify-send "$title" "$body" --app-name=zsh "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME" elif [[ "$platform" == "Darwin" ]]; then From 058711a7937922c3878ed947b88dab6c0e29a508 Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Fri, 6 Sep 2019 14:59:46 -0400 Subject: [PATCH 2/2] Apply README suggestions --- README.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index ce7c081..5731a5f 100644 --- a/README.rst +++ b/README.rst @@ -124,12 +124,13 @@ NOTE: This configuration option currently only works for Linux. **Notification Urgency Level** -By default non zero exit codes lead to critical notifications. -On some systems (KDE) critical notifications will never expire. -You can override notification urgency by setting the environment variable ``"AUTO_NOTIFY_URGENCY"`` to ``"low"``, ``"normal"``, or ``"critical``. +By default non zero exit codes lead to notifications marked as critical. +On some systems (e.g. KDE) critical notifications are not desirable as they will never expire. +You can override notification urgency by setting the environment variable ``"AUTO_NOTIFY_URGENCY"`` to ``low``, ``normal``, or ``critical``. NOTE: This configuration option currently only works for Linux. :: + # Force all notifications to have normal urgency export AUTO_NOTIFY_URGENCY="normal"