Script to turn on/off device if unread mail (gmail)
Posted: Fri Mar 17, 2023 9:45 am
Got a gmail account? Here is a simple script to turn on/off a device if you have unread email:
Replace "5" with your device id ..
checkEmail.sh:
crontab:
(check every 4 minutes)
Replace "5" with your device id ..
checkEmail.sh:
Code: Select all
#!/bin/bash
RET=`curl -u username@gmail.com:password --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "1" if /<(fullcount)>[^0]<\/\1>/;'`
if [ $RET == "1" ] ; then
tdtool --on 5
else
tdtool --off 5
fi
Code: Select all
*/4 * * * * ~/checkEmail.sh &> /dev/null