summaryrefslogtreecommitdiffstats
path: root/py3status
diff options
context:
space:
mode:
Diffstat (limited to 'py3status')
-rw-r--r--py3status/modules/imap.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/py3status/modules/imap.py b/py3status/modules/imap.py
index 2bb5923..9b5aa5d 100644
--- a/py3status/modules/imap.py
+++ b/py3status/modules/imap.py
@@ -20,6 +20,7 @@ class Py3status:
imap_server = '<IMAP_SERVER>'
mailbox = 'INBOX'
name = 'Mail: %unseen'
+ new_mail_color = ''
password = '<PASSWORD>'
port = '993'
user = '<USERNAME>'
@@ -31,14 +32,14 @@ class Py3status:
'cached_until': time() + self.cache_timeout
}
- new_mail_color = i3s_config['color_bad']
- response['full_text'] = 'blaa'
+ if not self.new_mail_color:
+ self.new_mail_color = i3s_config['color_bad']
if mail_count == 'N/A':
response['color'] = ''
response['full_text'] = mail_count
elif mail_count != 0:
- response['color'] = new_mail_color
+ response['color'] = self.new_mail_color
response['full_text'] = self.name.replace('%unseen', str(mail_count))
else:
response['color'] = ''
@@ -53,15 +54,16 @@ class Py3status:
try:
mail_count = 0
directories = self.mailbox.split(',')
+ connection = imaplib.IMAP4_SSL(self.imap_server, self.port)
+ connection.login(self.user, self.password)
for directory in directories:
- connection = imaplib.IMAP4_SSL(self.imap_server, self.port)
- connection.login(self.user, self.password)
connection.select(directory)
unseen_response = connection.search(None, self.criterion)
- connection.close()
mails = unseen_response[1][0].split()
mail_count += len(mails)
+
+ connection.close()
return mail_count
except: