I'm having quite some trouble doing that :
I'm using Conky on my Archlinux distro and coded a quick script in python to check if I have a new mail in my gmail. In my conkyrc this script executes every 5 minutes and returns a number of mails (0 if I don't have any). Works fine.
What I wanted to do is :
If the number of mail is > 0 then display a notification (a gnome-shell notification). The only problem I have now is that if I have unread mails (for example 4 mails unread), each 5 minutes, there will be a NEW notification saying that I have 4 mails unread. What I would like to do is checking if there is already a notification so that I don't have to display it again... Does anyone know how to solve that kind of problem ?
Here is my code :
#!/usr/bin/python
from gi.repository import Notify
from urllib.request import FancyURLopener
url = 'https://%s:%s@mail.google.com/mail/feed/atom' % ("username", "password")
opener = FancyURLopener()
page = opener.open(url)
contents = page.read().decode('utf-8')
ifrom = contents.index('<fullcount>') + 11
ito = contents.index('</fullcount>')
unread = contents[ifrom:ito]
print(unread)
if unread != "0" :
Notify.init ("New Mail")
Hello=Notify.Notification.new ("New mail","You have "+unread+" new mail(s)","/usr/share/icons/Faenza/actions/96/mail-forward.png")
Hello.show ()
I must precise that I'm quite new to python. Thanks in advance if anyone got a solution :)