This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/statusbar/sb-mailbox
David JULIEN d8f5743fb6
Merge branch 'dev' into mercury
displayselect: fix script + default config
mail: add univ-nantes account
      use env variables when possible
      update sb-mailbox
gnupg: use pinentry-gtk2 instead of curses
2022-10-17 23:01:34 +02:00

28 lines
981 B
Bash
Executable File

#!/usr/bin/env sh
######################################################################
# @author : swytch (adapted from Luke Smith - lukesmith.xyz)
# @file : sb-mailbox
# @license : GPLv3
# @created : Saturday Feb 13, 2021 18:15:13 CET
#
# @description : mail block for dwmblocks
######################################################################
unread=""
for acc in $(ls "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/)
do
new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc/*/new/ -type f | grep -iv "trash" | wc -l 2>/dev/null)"
if [ $new -gt 0 ]; then
[ -n "$(echo "$acc" | sed -n '/@centrale/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/@etu/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/@mailo/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/@posteo/p')" ] && box=""
unread="$unread/$box$new"
fi
done
[ -n "$unread" ] && unread="($(echo "$unread" | cut -c 2-))" || exit
printf "  %s%s " "$unread" "$icon"