From ac325a7caba6630538c39e1c0ffa192d866cdcff Mon Sep 17 00:00:00 2001 From: PukNgae Cryolitia Date: Mon, 16 Sep 2024 05:20:59 +0800 Subject: [PATCH] feat(bgnotify): add config to pass extra args (#12679) --- plugins/bgnotify/README.md | 1 + plugins/bgnotify/bgnotify.plugin.zsh | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md index 33d529f15..1389def86 100644 --- a/plugins/bgnotify/README.md +++ b/plugins/bgnotify/README.md @@ -38,6 +38,7 @@ One can configure a few things: - `bgnotify_bell` enabled or disables the terminal bell (default true) - `bgnotify_threshold` sets the notification threshold time (default 6 seconds) - `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon. +- `bgnotify_extraargs` appends extra args to notifier (e.g. `-e` for notify-send to create a transient notification) Use these by adding a function definition before the your call to source. Example: diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 7de6f9a91..f6ffb6ed5 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -117,15 +117,15 @@ function bgnotify { local icon="$3" if (( ${+commands[terminal-notifier]} )); then # macOS local term_id=$(bgnotify_programid) - terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} &>/dev/null + terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} ${=bgnotify_extraargs:-} &>/dev/null elif (( ${+commands[growlnotify]} )); then # macOS growl - growlnotify -m "$title" "$message" + growlnotify -m "$title" "$message" ${=bgnotify_extraargs:-} elif (( ${+commands[notify-send]} )); then - notify-send "$title" "$message" ${=icon:+--icon "$icon"} + notify-send "$title" "$message" ${=icon:+--icon "$icon"} ${=bgnotify_extraargs:-} elif (( ${+commands[kdialog]} )); then # KDE - kdialog --title "$title" --passivepopup "$message" 5 + kdialog --title "$title" --passivepopup "$message" 5 ${=bgnotify_extraargs:-} elif (( ${+commands[notifu]} )); then # cygwin - notifu /m "$message" /p "$title" ${=icon:+/i "$icon"} + notifu /m "$message" /p "$title" ${=icon:+/i "$icon"} ${=bgnotify_extraargs:-} fi }