summaryrefslogtreecommitdiff
path: root/plugins/zbell/zbell.plugin.zsh
diff options
context:
space:
mode:
authorMatthieu Baerts <matttbe@gmail.com>2021-12-29 10:38:00 +0100
committerGitHub <noreply@github.com>2021-12-29 10:38:00 +0100
commit8d58994d765de350f1dc66132eaab0358e10a4ab (patch)
tree3ed3d60d607443c5089bf385238702b8ac358b6e /plugins/zbell/zbell.plugin.zsh
parent65bbd24eec6b64f2f526c974781f08373277be0c (diff)
downloadzsh-8d58994d765de350f1dc66132eaab0358e10a4ab.tar.gz
zsh-8d58994d765de350f1dc66132eaab0358e10a4ab.tar.bz2
zsh-8d58994d765de350f1dc66132eaab0358e10a4ab.zip
feat(zbell): add option not to use notify-send (#10082)
Diffstat (limited to 'plugins/zbell/zbell.plugin.zsh')
-rw-r--r--plugins/zbell/zbell.plugin.zsh17
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins/zbell/zbell.plugin.zsh b/plugins/zbell/zbell.plugin.zsh
index 6d0416502..8e374029b 100644
--- a/plugins/zbell/zbell.plugin.zsh
+++ b/plugins/zbell/zbell.plugin.zsh
@@ -29,18 +29,31 @@ autoload -Uz regexp-replace || return
# initialize zbell_ignore if not set
(( ${+zbell_ignore} )) || zbell_ignore=($EDITOR $PAGER)
+# initialize zbell_use_notify_send if not set
+(( ${+zbell_use_notify_send} )) || zbell_use_notify_send=true
+
# initialize it because otherwise we compare a date and an empty string
# the first time we see the prompt. it's fine to have lastcmd empty on the
# initial run because it evaluates to an empty string, and splitting an
# empty string just results in an empty array.
zbell_timestamp=$EPOCHSECONDS
+# UI notification function
+# $1: command
+# $2: duration in seconds
+zbell_ui_notify() {
+ [[ $zbell_use_notify_send != "true" ]] && return
+
+ if type notify-send > /dev/null; then
+ notify-send -i terminal "Command completed in ${2}s:" $1
+ fi
+}
+
# default notification function
# $1: command
# $2: duration in seconds
zbell_notify() {
- type notify-send > /dev/null && \
- notify-send -i terminal "Command completed in ${2}s:" $1
+ zbell_ui_notify "${@}"
print -n "\a"
}