Get CheckGMail to Use Ubuntu Notifications

My favorite application for checking GMail on my computer isCheckGmail as you can control the unread messages from the system tray without needing to open an application.


My only issue with it is I don't like the notification window that lets you know you have new emails, I would much rather have the native notifications from Ubuntu.





This is how that can be done:
First you need the the libnotify package which is easy in Ubuntu (sudo apt-get install libnotify) now you can make your own notifications by typing notify-send "Hello World"
If you now go into the CheckGmail preferences and set the pop up time to 0 secs to and put the following into "Command to execute on new mail":

if [ %m = 1 ] ; then mess="Message"; else mess="Messages"; fi; notify-send "You have %m New $mess" -i ~/bin/gmail.png
The %m is a variable of how many emails you have just recived so a lot of the code is determining whether to use the plural or not. The last bit is a link to a Gmail icon.