Archive

Posts Tagged ‘gmail’

Improved Google mail number of unread emails script

January 27th, 2010 Ed No comments

Since writing “Get number of unread posts from google mail”, I realised that I didn’t care about a lot of emails that I get on a regular basis, things like ebuyer emails, stock-market alerts etc. I only want to be notified when I’ve got emails from real people.

By applying a “Newsletters” label on GMail to all automated messages by filtering messages, I can now see how many unread emails I have, then subtract the number of unread newsletters I have, and flash the ambient light that number of times.

Grab getGoogleMail.sh, change the usernames and passwords, and change “Newsletters” to whatever your google label is. Then use the $count variable to do whatever you want.

Categories: Web Tags: , , , , ,

Get number of unread posts from google mail

November 1st, 2009 Ed No comments

Here’s a simple bash script that gets the number of unread messages, and runs a command that does something with that. In my case, a java program that puts a message on a MQTT topic, which indirectly flashes an ambient light.

#!/bin/bash
while (true)
do

rm atom
rm atom_process

wget https://gmail.google.com/gmail/feed/atom --user=XXXXX --password=XXXXX 2&>1  /dev/null

cat atom | grep fullcount > atom_process
count=`sed -n -e 's/.*>\(.*\)<.*/\1/p' atom_process`

java -jar /home/ed/rrd/MQTTRunner.jar mpc_google 3 $count
sleep 60

done

Categories: Web Tags: ,