mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-29 04:53:17 +02:00
[!] bgnotify: always nofity when exceeding threshold
This commit is contained in:
parent
c8ea383538
commit
ea61f6892e
1 changed files with 4 additions and 10 deletions
|
|
@ -16,7 +16,7 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi
|
||||||
elapsed="$(( $3 % 60 ))s"
|
elapsed="$(( $3 % 60 ))s"
|
||||||
(( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
(( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
||||||
(( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $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
|
fi
|
||||||
|
|
||||||
|
|
@ -32,11 +32,7 @@ currentWindowId () {
|
||||||
|
|
||||||
bgnotify () { ## args: (title, subtitle)
|
bgnotify () { ## args: (title, subtitle)
|
||||||
if hash terminal-notifier 2>/dev/null; then #osx
|
if hash terminal-notifier 2>/dev/null; then #osx
|
||||||
[[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2';
|
terminal-notifier -message "$2" -title "$1" >/dev/null ||
|
||||||
[[ "$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
|
|
||||||
elif hash growlnotify 2>/dev/null; then #osx growl
|
elif hash growlnotify 2>/dev/null; then #osx growl
|
||||||
growlnotify -m "$1" "$2"
|
growlnotify -m "$1" "$2"
|
||||||
elif hash notify-send 2>/dev/null; then #ubuntu gnome!
|
elif hash notify-send 2>/dev/null; then #ubuntu gnome!
|
||||||
|
|
@ -62,10 +58,8 @@ bgnotify_end() {
|
||||||
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
|
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
|
||||||
past_threshold=$(( elapsed >= bgnotify_threshold ))
|
past_threshold=$(( elapsed >= bgnotify_threshold ))
|
||||||
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
|
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
|
||||||
if [ $(currentWindowId) != "$bgnotify_windowid" ]; then
|
print -n "\a"
|
||||||
print -n "\a"
|
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
|
||||||
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
bgnotify_timestamp=0 #reset it to 0!
|
bgnotify_timestamp=0 #reset it to 0!
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue