mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-13 09:20:09 +00:00
feat(bgnotify): add icon parameter (#12055)
This commit is contained in:
parent
44a5513fcb
commit
38e80e9f21
1 changed files with 8 additions and 15 deletions
|
@ -52,10 +52,10 @@ function bgnotify_formatted {
|
||||||
(( $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"
|
||||||
|
|
||||||
if [[ $1 -eq 0 ]]; then
|
if [[ $exit_status -eq 0 ]]; then
|
||||||
bgnotify "#win (took $elapsed)" "$2"
|
bgnotify "#win (took $elapsed)" "$cmd"
|
||||||
else
|
else
|
||||||
bgnotify "#fail (took $elapsed)" "$2"
|
bgnotify "#fail (took $elapsed)" "$cmd"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ function bgnotify_appid {
|
||||||
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )) && (( ${+commands[jq]} )); then # wayland+sway
|
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )) && (( ${+commands[jq]} )); then # wayland+sway
|
||||||
# output is "app_id, container id" (Alacritty, 1694)
|
# output is "app_id, container id" (Alacritty, 1694)
|
||||||
swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | {app_id, id} | join(", ")'
|
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
|
xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5
|
||||||
else
|
else
|
||||||
echo $EPOCHSECONDS
|
echo $EPOCHSECONDS
|
||||||
|
@ -76,6 +76,7 @@ function bgnotify_appid {
|
||||||
function bgnotify {
|
function bgnotify {
|
||||||
local title="$1"
|
local title="$1"
|
||||||
local message="$2"
|
local message="$2"
|
||||||
|
local icon="$3"
|
||||||
if (( ${+commands[terminal-notifier]} )); then # macOS
|
if (( ${+commands[terminal-notifier]} )); then # macOS
|
||||||
local term_id="${bgnotify_termid%%,*}" # remove window id
|
local term_id="${bgnotify_termid%%,*}" # remove window id
|
||||||
if [[ -z "$term_id" ]]; then
|
if [[ -z "$term_id" ]]; then
|
||||||
|
@ -85,23 +86,15 @@ function bgnotify {
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$term_id" ]]; then
|
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id" -sender "$term_id"} &>/dev/null
|
||||||
terminal-notifier -message "$message" -title "$title" &>/dev/null
|
|
||||||
else
|
|
||||||
terminal-notifier -message "$message" -title "$title" -activate "$term_id" -sender "$term_id" &>/dev/null
|
|
||||||
fi
|
|
||||||
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
||||||
growlnotify -m "$title" "$message"
|
growlnotify -m "$title" "$message"
|
||||||
elif (( ${+commands[notify-send]} )); then
|
elif (( ${+commands[notify-send]} )); then
|
||||||
if [[ -n $ALACRITTY_WINDOW_ID ]]; then
|
notify-send "$title" "$message" ${=icon:+--icon "$icon"}
|
||||||
notify-send -i Alacritty "$title" "$message"
|
|
||||||
else
|
|
||||||
notify-send "$title" "$message"
|
|
||||||
fi
|
|
||||||
elif (( ${+commands[kdialog]} )); then # KDE
|
elif (( ${+commands[kdialog]} )); then # KDE
|
||||||
kdialog --title "$title" --passivepopup "$message" 5
|
kdialog --title "$title" --passivepopup "$message" 5
|
||||||
elif (( ${+commands[notifu]} )); then # cygwin
|
elif (( ${+commands[notifu]} )); then # cygwin
|
||||||
notifu /m "$message" /p "$title"
|
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue