aboutsummaryrefslogtreecommitdiffstats
path: root/mail-overview/mail-notify.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-13 17:32:28 +0200
committerDanilo M. <danix@danix.xyz>2026-09-13 17:32:28 +0200
commitc4c4d9b0b05d4d327534487fc9cd412f8f34571f (patch)
treed26a70755e6b10560504fd3787cda19042b7ad57 /mail-overview/mail-notify.sh
parent3df934d85aee0d0db20c0fc522d60b0178f4018a (diff)
downloadquickshell-c4c4d9b0b05d4d327534487fc9cd412f8f34571f.tar.gz
quickshell-c4c4d9b0b05d4d327534487fc9cd412f8f34571f.zip
feat(mail-overview): title, icon and spaced bullet body
A live test showed the old title ("<label> · N new") read poorly and the body packed the rows into one block. Title is now "New Mail - <label> (N)" with the mail-unread icon, and each message is a bullet on its own line with a blank line between. +N more counts rows, not physical lines, so the blank lines do not skew it.
Diffstat (limited to 'mail-overview/mail-notify.sh')
-rwxr-xr-xmail-overview/mail-notify.sh21
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("&"; "&amp;") | gsub("<"; "&lt;") | gsub(">"; "&gt;")
' 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 &