add email checker app

pull/20/head
Botspot
parent cdac58d978
commit 53d9feaab0

@ -0,0 +1,4 @@
Continuously checks for new emails and display a notification if there are any.
When you click install, a window will appear for you to enter the email account's information and the time interval to check.
If you want to change the settings later, just click the Install button again.
Originally adapted from: https://learn.adafruit.com/raspberry-pi-e-mail-notifier-using-leds/python-script

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

@ -0,0 +1,65 @@
#!/bin/bash
DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"
function error {
echo -e "\\e[91m$1\\e[39m"
exit 1
}
#use the error function often!
#If a certain command is necessary for installation to continue, then add this to the end of it:
# || error 'reason'
#example below:
# Get dependencies
#"${DIRECTORY}/pkg-install" "zenity python3-pip" "$(dirname "$0")" || exit 1
#sudo pip3 install imapclient || error "Failed to install imapclient!"
output="$(yad --form --center --width=400 --separator='\n' \
--title="Email Checker Settings" --window-icon="$(dirname "$0")/icon-64.png" \
--field='IMAP Server:' 'outlook.office365.com' \
--field='Email:' 'j.allen.marchand@outlook.com' \
--field='Password:' '' \
--field='Folder:' 'Inbox' \
--field='Check interval: (seconds)' '60' \
--button=OK!${DIRECTORY}/icons/check.png:0)"
button=$?
[ $button -ne 0 ]&&error "User exited."
echo "Output: ${output}EOO"
if [ -d ~/raspi-email-checker ];then
gio trash ~/raspi-email-checker
echo -e "\\e[91mWARNING: Moved the raspi-email-checker folder to trash instead of deleting.
The checkmail.py script inside may contain a password!\\e[39m"
fi
git clone https://github.com/Botspot/raspi-email-checker || error 'Failed to clone repository!'
#hostname
sed -i "s/hostname2replace/$(echo "$output" | sed "1q;d")/g" ~/raspi-email-checker/checkmail.py
#email
sed -i "s/email2replace/$(echo "$output" | sed "2q;d")/g" ~/raspi-email-checker/checkmail.py
#password
sed -i "s/password2replace/$(echo "$output" | sed "3q;d")/g" ~/raspi-email-checker/checkmail.py
#mailbox
sed -i "s/mailbox2replace/$(echo "$output" | sed "4q;d")/g" ~/raspi-email-checker/checkmail.py
#checkinterval
sed -i "s/checkinterval2replace/$(echo "$output" | sed "5q;d")/g" ~/raspi-email-checker/checkmail.py
#run on boot
mkdir -p ~/.config/autostart
echo "[Desktop Entry]
Name=Email Checker
Comment=Displays a pop-up window if your $(echo "$output" | sed "4q;d") folder contains any unread emails.
Exec=sudo python ${HOME}/raspi-email-checker/checkmail.py
X-GNOME-Autostart-enabled=true
Hidden=false
Icon=$(dirname "$0")/icon-64.png
NoDisplay=false" > ~/.config/autostart/checkmail.desktop

@ -0,0 +1,18 @@
#!/bin/bash
DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"
function error {
echo -e "\\e[91m$1\\e[39m"
exit 1
}
if [ -d ~/raspi-email-checker ];then
gio trash ~/raspi-email-checker
echo -e "\\e[91mWARNING: Moved the raspi-email-checker folder to trash instead of deleting.
The checkmail.py script inside may contain a password!\\e[39m"
fi
rm -f ~/.config/autostart/checkmail.desktop
"${DIRECTORY}/purge-installed" "$(dirname "$0")" || exit 1

@ -0,0 +1 @@
https://github.com/Botspot/raspi-email-checker
Loading…
Cancel
Save