First commit

This commit is contained in:
2025-07-22 02:30:15 +02:00
commit e9441f563b
66 changed files with 4401 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e
cd -- "$(dirname -- "$0")"
_DIRNAME="$(pwd)"
source ~/.config/polybar/imap_creds
if [[ -n $1 ]] && [[ $1 == "count" ]]
then
_COUNT=$(curl -u "$_USER:$_PASSWD" "imaps://$_SERVER" -X "STATUS $_FOLDER (UNSEEN)" 2>/dev/null | \
sed -e 's/)\r//' -e 's/.*UNSEEN //')
printf "%s" "$_COUNT"
(( _COUNT == 0 )) && exit 0
exit 1
fi
if [[ -n $1 ]] && [[ $1 == "fetch" ]]
then
_UNSEEN="$(curl -u \""$_USER":"$_PASSWD"\" "imaps://$_SERVER/$_FOLDER" -X "SEARCH UNSEEN" 2>/dev/null | \
sed -e "s/\\r//" -e "s/* SEARCH //" -e "s/ /,/g")"
_MAILS=$(curl -v -u "$_USER:$_PASSWD" "imaps://$_SERVER/$_FOLDER" -X "FETCH $_UNSEEN BODY.PEEK[HEADER.FIELDS (From Subject)]" 2>&1 | \
grep -E "From:|Subject:" | sed -e 's/< //' -e 's/Subject/\nSubject/')
dunstify -I ../icons/gmail.svg \
"" "$_MAILS"
printf "%s" "$_MAILS"
exit 0
fi
cat <<EOF
Usage:
mailbox.sh count => Count unseen mails in $_FOLDER
mailbox.sh fetch => Fetch "From:" and "Subject:" from unseen mails in $_FOLDER
EOF