Tuesday, May 15, 2012

track gmail unread messages with conky in two steps

Step 1:
Here is how you can make conky show how many unread messages you have in your gmail accounts. In my case I wanted to track two gmail accounts so I added the following lines to my conkyrc configuration file.

GMAIL 
<user_1>@gmail.com $alignr ${execi 30 ~/scripts/gmail/checkgmail.sh '<user_1>' '<password_1>'}
<account_2>@gmail.com $alignr ${execi 30 ~/scripts/gmail/checkgmail.sh '<user_name_2>' '<password_2>'}

         The "execi 30" tells conky to run the "checkgmail.sh" script every 30 seconds.
         Change <user_N> and <password_N> with your gmail username and password.

Step 2:
In addition to the above mentioned lines added to the conky configuration file I slightly modified this script I found on the crunchbang linux forums.It seems there are some kind of problem in Germany with "gmail" not beeing allowed to use this name, so this is the modified version of the script that works for me in Germany:
./checkgmail.sh
#!/bin/bash

wget -q -O - https://mail.google.com/mail/feed/atom --http-user="$1"@gmail.com --http-password="$2" -
-no-check-certificate | grep fullcount | sed 's/[^0-9]//g'

exit

It takes the gmail account name and the password as parameters of the conkyrc file. Don't forget to make the script executable.
Et violĂ , the lines with gmail accounts appear at the bottom of conky showing the number of unread messages for each gmail account:


1 comment:

  1. Oh thank you so for posting this. This is going to be tremendous help for me and i am sure other also. You're always posting such great stuff, I wonder how you do it. But please keep it up ! ;)

    ReplyDelete