2021-02-13 20:17:23 +01:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
######################################################################
|
2021-02-15 00:12:27 +01:00
|
|
|
# @author : swytch (adapted from Luke Smith - lukesmith.xyz)
|
2021-02-13 20:17:23 +01:00
|
|
|
# @file : sb-mailbox
|
2021-02-15 00:37:34 +01:00
|
|
|
# @license : GPLv3
|
2021-02-13 20:17:23 +01:00
|
|
|
# @created : Saturday Feb 13, 2021 18:15:13 CET
|
|
|
|
#
|
|
|
|
# @description : mail block for dwmblocks
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
|
2021-02-16 15:04:19 +01:00
|
|
|
unread=""
|
|
|
|
for acc in $(ls "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/)
|
|
|
|
do
|
2022-10-25 12:02:17 +02:00
|
|
|
new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv -e "trash" -e "drafts" | wc -l 2>/dev/null)"
|
2021-02-16 20:58:23 +01:00
|
|
|
if [ $new -gt 0 ]; then
|
2022-10-18 10:55:16 +02:00
|
|
|
box=""
|
2022-11-04 14:50:41 +01:00
|
|
|
[ -n "$(echo "$acc" | sed -n '/univ/p')" ] && box=""
|
|
|
|
[ -n "$(echo "$acc" | sed -n '/mailo/p')" ] && box=""
|
|
|
|
[ -n "$(echo "$acc" | sed -n '/posteo/p')" ] && box=""
|
2022-11-01 23:21:45 +01:00
|
|
|
unread="$unread/$box$new"
|
2021-02-16 15:04:19 +01:00
|
|
|
fi
|
|
|
|
done
|
2022-10-19 23:27:18 +02:00
|
|
|
[ -n "$unread" ] && unread="$(echo "$unread" | cut -c 2-)" || exit
|
2021-02-13 20:17:23 +01:00
|
|
|
|
2021-02-16 20:53:50 +01:00
|
|
|
printf " %s%s " "$unread" "$icon"
|