summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJohan Sjöblom <sjoblomj88@gmail.com>2023-11-23 10:11:08 +0000
committerGitHub <noreply@github.com>2023-11-23 11:11:08 +0100
commit38e80e9f21ee981b5f616003c788dcbb9267466c (patch)
tree4d1867457026204006675ae23131e230bf64c2fb /plugins
parent44a5513fcb3f528afb056490908d216f926497e6 (diff)
downloadzsh-38e80e9f21ee981b5f616003c788dcbb9267466c.tar.gz
zsh-38e80e9f21ee981b5f616003c788dcbb9267466c.tar.bz2
zsh-38e80e9f21ee981b5f616003c788dcbb9267466c.zip
feat(bgnotify): add icon parameter (#12055)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/bgnotify/bgnotify.plugin.zsh23
1 files changed, 8 insertions, 15 deletions
diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
index 493a20815..a4a7b621b 100644
--- a/plugins/bgnotify/bgnotify.plugin.zsh
+++ b/plugins/bgnotify/bgnotify.plugin.zsh
@@ -52,10 +52,10 @@ function bgnotify_formatted {
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
- if [[ $1 -eq 0 ]]; then
- bgnotify "#win (took $elapsed)" "$2"
+ if [[ $exit_status -eq 0 ]]; then
+ bgnotify "#win (took $elapsed)" "$cmd"
else
- bgnotify "#fail (took $elapsed)" "$2"
+ bgnotify "#fail (took $elapsed)" "$cmd"
fi
}
@@ -66,7 +66,7 @@ function bgnotify_appid {
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )) && (( ${+commands[jq]} )); then # wayland+sway
# output is "app_id, container id" (Alacritty, 1694)
swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | {app_id, id} | join(", ")'
- elif [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then
+ elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then
xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5
else
echo $EPOCHSECONDS
@@ -76,6 +76,7 @@ function bgnotify_appid {
function bgnotify {
local title="$1"
local message="$2"
+ local icon="$3"
if (( ${+commands[terminal-notifier]} )); then # macOS
local term_id="${bgnotify_termid%%,*}" # remove window id
if [[ -z "$term_id" ]]; then
@@ -85,23 +86,15 @@ function bgnotify {
esac
fi
- if [[ -z "$term_id" ]]; then
- terminal-notifier -message "$message" -title "$title" &>/dev/null
- else
- terminal-notifier -message "$message" -title "$title" -activate "$term_id" -sender "$term_id" &>/dev/null
- fi
+ terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id" -sender "$term_id"} &>/dev/null
elif (( ${+commands[growlnotify]} )); then # macOS growl
growlnotify -m "$title" "$message"
elif (( ${+commands[notify-send]} )); then
- if [[ -n $ALACRITTY_WINDOW_ID ]]; then
- notify-send -i Alacritty "$title" "$message"
- else
- notify-send "$title" "$message"
- fi
+ notify-send "$title" "$message" ${=icon:+--icon "$icon"}
elif (( ${+commands[kdialog]} )); then # KDE
kdialog --title "$title" --passivepopup "$message" 5
elif (( ${+commands[notifu]} )); then # cygwin
- notifu /m "$message" /p "$title"
+ notifu /m "$message" /p "$title" ${=icon:+/i "$icon"}
fi
}