summaryrefslogtreecommitdiff
path: root/bin/email
blob: 84e923edb58c0d1c4d91e83de8e0d2d33c89e696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /usr/bin/env bash

# Necessary to see the notification
export DISPLAY=:0

# Get all emails
mbsync -a

new_mails=$(find $HOME/.mail -path '*/new/*' -type f)
subjects=$(cat $(echo -e ${new_mails/'\n'/' '}) | grep "^Subject: " | sed "s/^Subject: //g")

if [[ ! -z ${new_mails} ]]; then
    /usr/bin/notify-send -t 3 "New mail(s)!" "${subjects}"
fi

echo "Email last checked on $(date)".