diff options
Diffstat (limited to 'mail-overview/mail-notify.sh')
| -rwxr-xr-x | mail-overview/mail-notify.sh | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/mail-overview/mail-notify.sh b/mail-overview/mail-notify.sh index 8309b51..f36bef2 100755 --- a/mail-overview/mail-notify.sh +++ b/mail-overview/mail-notify.sh @@ -93,16 +93,17 @@ parse_accounts() { # Malformed JSON prints nothing and succeeds. A notification with no body is # still worth sending: the summary already carries the account and the count. build_body() { - local json="$1" total="$2" shown + local json="$1" total="$2" shown rowtext body - local body - body="$(printf '%s' "$json" | jq -r ' - .[] | ((.authors // "(unknown)") + " — " + (.subject // "(no subject)")) + rowtext="$(printf '%s' "$json" | jq -r ' + .[] | "• " + ((.authors // "(unknown)") + " — " + (.subject // "(no subject)")) | gsub("&"; "&") | gsub("<"; "<") | gsub(">"; ">") ' 2>/dev/null)" || return 0 - [[ -n "$body" ]] || return 0 + [[ -n "$rowtext" ]] || return 0 + + shown="$(printf '%s\n' "$rowtext" | wc -l)" + body="$(printf '%s\n' "$rowtext" | awk 'NR>1{print ""} 1')" - shown="$(printf '%s\n' "$body" | wc -l)" printf '%s' "$body" if [[ "$total" -gt "$shown" ]]; then printf '\n+%d more' "$((total - shown))" @@ -167,8 +168,8 @@ notify_account() { if ! command -v dunstify >/dev/null 2>&1; then # No actions available, but a notification without a click is still # worth having. - notify-send -a mail-overview -u normal -t 10000 \ - "$label · $count new" "$body" + notify-send -a mail-overview -i mail-unread -u normal -t 10000 \ + "New Mail - $label ($count)" "$body" return 0 fi @@ -176,10 +177,10 @@ notify_account() { # clicked. Without this the loop would stall for the full timeout on # every account, and a five-account batch would take most of a minute. ( - if [[ "$(dunstify -a mail-overview -u normal -t 10000 -b \ + if [[ "$(dunstify -a mail-overview -i mail-unread -u normal -t 10000 -b \ -h "string:x-dunst-stack-tag:mail-$key" \ -A "default,open" \ - "$label · $count new" "$body")" == "default" ]]; then + "New Mail - $label ($count)" "$body")" == "default" ]]; then "$HOME/bin/qtmaildir" & fi ) >/dev/null 2>&1 & |
