summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrixx <rixx-git@cutebit.de>2015-03-16 09:44:44 +0100
committerrixx <rixx-git@cutebit.de>2015-03-16 09:55:05 +0100
commit374fd321e29a40f8e00a7d4604f10c88495279fe (patch)
treecf1d680117f3d0e169092cd514633ab378d17580
parentd8bf36f2aa8a190b63f0934bb9ef7039ac5be545 (diff)
parentb133eaa38c047827962c2913a3bd7d45f0942a7a (diff)
Free choice of color for unread mails
-rw-r--r--py3status/modules/imap.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/py3status/modules/imap.py b/py3status/modules/imap.py
index f76f7f9..9b5aa5d 100644
--- a/py3status/modules/imap.py
+++ b/py3status/modules/imap.py
@@ -16,9 +16,11 @@ class Py3status:
# available configuration parameters
cache_timeout = 60
criterion = 'UNSEEN'
+ hide_if_zero = False
imap_server = '<IMAP_SERVER>'
mailbox = 'INBOX'
- name = 'Mail'
+ name = 'Mail: %unseen'
+ new_mail_color = ''
password = '<PASSWORD>'
port = '993'
user = '<USERNAME>'
@@ -27,17 +29,24 @@ class Py3status:
mail_count = self._get_mail_count()
response = {
- 'cached_until': time() + self.cache_timeout,
- 'full_text': '{}: {}'.format(self.name, mail_count)
+ 'cached_until': time() + self.cache_timeout
}
- new_mail_color = i3s_config['color_good']
- check_failed_color = i3s_config['color_bad']
+ if not self.new_mail_color:
+ self.new_mail_color = i3s_config['color_bad']
if mail_count == 'N/A':
- response['color'] = check_failed_color
+ 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'] = ''
+ if self.hide_if_zero:
+ response['full_text'] = ''
+ else:
+ response['full_text'] = self.name.replace('%unseen', '0')
return response