From 2c0059707f3abf795402cad839bd327a263647d3 Mon Sep 17 00:00:00 2001 From: "61825162+CaderIdris@users.noreply.github.com" <61825162+CaderIdris@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:15:09 +0100 Subject: [PATCH] Added icon support for linux Added: AUTO_NOTIFY_ICON_SUCCESS environmental variable, represents path to icon for notify-send to display on command success Added: AUTO_NOTIFY_ICON_FAILURE environmental variable, represents path to icon for notify-send to display on command failure Added: --icon option when icon path is present for notify-send, no additional argument added if environmental variable not specified Modified: Version number to pass test --- auto-notify.plugin.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index 64174b9..93bd895 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -1,4 +1,4 @@ -export AUTO_NOTIFY_VERSION="0.8.1" +export AUTO_NOTIFY_VERSION="0.8.2" # Time it takes for a notification to expire [[ -z "$AUTO_NOTIFY_EXPIRE_TIME" ]] && @@ -6,6 +6,7 @@ export AUTO_NOTIFY_VERSION="0.8.1" # Threshold in seconds for when to automatically show a notification [[ -z "$AUTO_NOTIFY_THRESHOLD" ]] && export AUTO_NOTIFY_THRESHOLD=10 + # List of commands/programs to ignore sending notifications for [[ -z "$AUTO_NOTIFY_IGNORE" ]] && export AUTO_NOTIFY_IGNORE=( @@ -52,11 +53,18 @@ function _auto_notify_message() { if [[ "$platform" == "Linux" ]]; then local urgency="normal" local transient="--hint=int:transient:1" + local icon=${AUTO_NOTIFY_ICON_SUCCESS:-""} if [[ "$exit_code" != "0" ]]; then urgency="critical" transient="" + icon=${AUTO_NOTIFY_ICON_FAILURE:-""} fi - notify-send "$title" "$body" --app-name=zsh $transient "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME" + local icon_arg="" + if [[ -n "$icon" ]]; then + icon_arg=" --icon=$icon" + fi + + notify-send "$title" "$body" --app-name=zsh $transient "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME$icon_arg" elif [[ "$platform" == "Darwin" ]]; then osascript \ -e 'on run argv' \