You are not logged in.
Hi there, I have conky piped into a dzen panel, and I'm trying to get conky to echo my unread mail count whenever the # is >0. It's just not working for me, and I was wondering what I did incorrectly.
I have the 3 following files.
~/.conkyrc
background yes
out_to_console yes
out_to_x no
update_interval 1
TEXT
${execi 60 /home/nil/mail-notify}
~/mail-notify
#! /bin/bash
gmail=$(python /home/nil/gmail.py)
if [ $gmail -gt 0 ]; then
echo "$gmail"
fi
~/gmail.py
#!/usr/bin/env python
# This is a script that checkes the gmail unread count.
from urllib.request import FancyURLopener
username = 'myusername'
password = 'mypasswd'
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)
gmail.py was taken from the archwiki page, and I've confirmed it to be working (I censored my user name and password here). What gmail.py does is output an integer representing your unread mail count.
Similarly, Conky's code and the mail-notify script run fine. If I rewrite mail-notify's conditional to be "if [ 1 -gt 0 ]; then", then it will successfully output the unread mail count. Hence the problem lies in the scripting of the if condition. mail-notify should run gmail.py, if the output count is >0, then it should echo that number. Else it does nothing. Any help is appreciated!
Last edited by nil (2013-08-19 23:40:14)
Offline
Presumably the script is called gmail.py, not gmail1.py?
Offline
Presumably the script is called gmail.py, not gmail1.py?
Oops, sorry, that was a typo when writing up this post.
Offline
What happens when you run the script from the terminal with debug on?
Offline
Wait, what am I kidding? That does work. Never mind I'm really silly. I simplified my problem down here to try to reproduce the problem down to its core, but it ended up solving it somewhere in the end.
Offline