From 039a0f3d213aec6637b4194eca864c94597541ff Mon Sep 17 00:00:00 2001 From: Sinkerine Date: Mon, 9 Apr 2018 16:21:33 -0400 Subject: [PATCH] [!] bgnotify: always nofity when exceeding threshold --- plugins/bgnotify/bgnotify.plugin.zsh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 459f5214e..463b1cf06 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -16,7 +16,7 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi elapsed="$(( $3 % 60 ))s" (( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed" (( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed" - [ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2" + [ $1 -eq 0 ] && bgnotify "#done (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2" } fi @@ -32,11 +32,7 @@ currentWindowId () { bgnotify () { ## args: (title, subtitle) if hash terminal-notifier 2>/dev/null; then #osx - [[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2'; - [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal'; - ## now call terminal-notifier, (hopefully with $term_id!) - [ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null || - terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null + terminal-notifier -message "$2" -title "$1" >/dev/null || elif hash growlnotify 2>/dev/null; then #osx growl growlnotify -m "$1" "$2" elif hash notify-send 2>/dev/null; then #ubuntu gnome! @@ -62,10 +58,8 @@ bgnotify_end() { elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) past_threshold=$(( elapsed >= bgnotify_threshold )) if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then - if [ $(currentWindowId) != "$bgnotify_windowid" ]; then - print -n "\a" - bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" - fi + print -n "\a" + bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" fi bgnotify_timestamp=0 #reset it to 0! }