mirror of
https://github.com/powerline/powerline.git
synced 2025-07-23 13:55:45 +02:00
Add gradient to email_imap_alert segment
Colors probably need to be revised Fixes #301
This commit is contained in:
parent
83517f65b9
commit
004e6a8b46
@ -7,6 +7,7 @@
|
|||||||
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] },
|
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] },
|
||||||
"time:divider": { "fg": "gray5", "bg": "gray2" },
|
"time:divider": { "fg": "gray5", "bg": "gray2" },
|
||||||
"email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] },
|
"email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] },
|
||||||
|
"email_alert_gradient": { "fg": "white", "bg": "yellow_orange_red", "attr": ["bold"] },
|
||||||
"hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
"hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
||||||
"weather": { "fg": "gray8", "bg": "gray0" },
|
"weather": { "fg": "gray8", "bg": "gray0" },
|
||||||
"weather_temp_gradient": { "fg": "blue_red", "bg": "gray0" },
|
"weather_temp_gradient": { "fg": "blue_red", "bg": "gray0" },
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] },
|
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] },
|
||||||
"time:divider": { "fg": "gray5", "bg": "gray2" },
|
"time:divider": { "fg": "gray5", "bg": "gray2" },
|
||||||
"email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] },
|
"email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] },
|
||||||
|
"email_alert_gradient": { "fg": "white", "bg": "yellow_orange_red", "attr": ["bold"] },
|
||||||
"hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
"hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
||||||
"weather": { "fg": "gray8", "bg": "gray0" },
|
"weather": { "fg": "gray8", "bg": "gray0" },
|
||||||
"weather_temp_gradient": { "fg": "blue_red", "bg": "gray0" },
|
"weather_temp_gradient": { "fg": "blue_red", "bg": "gray0" },
|
||||||
|
@ -693,12 +693,23 @@ class EmailIMAPSegment(KwThreadedSegment):
|
|||||||
return None
|
return None
|
||||||
except imaplib.IMAP4.error as e:
|
except imaplib.IMAP4.error as e:
|
||||||
unread_count = str(e)
|
unread_count = str(e)
|
||||||
|
return unread_count
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def render_one(unread_count, max_msgs=None, **kwargs):
|
||||||
if not unread_count:
|
if not unread_count:
|
||||||
return None
|
return None
|
||||||
return [{
|
elif type(unread_count) != int or not max_msgs:
|
||||||
'highlight_group': 'email_alert',
|
return [{
|
||||||
'contents': str(unread_count),
|
'contents': str(unread_count),
|
||||||
}]
|
'highlight_group': 'email_alert',
|
||||||
|
}]
|
||||||
|
else:
|
||||||
|
return [{
|
||||||
|
'contents': str(unread_count),
|
||||||
|
'highlight_group': ['email_alert_gradient', 'email_alert'],
|
||||||
|
'gradient_level': unread_count * 100.0 / max_msgs,
|
||||||
|
}]
|
||||||
|
|
||||||
|
|
||||||
email_imap_alert = with_docstring(EmailIMAPSegment(),
|
email_imap_alert = with_docstring(EmailIMAPSegment(),
|
||||||
@ -714,8 +725,12 @@ email_imap_alert = with_docstring(EmailIMAPSegment(),
|
|||||||
e-mail server port
|
e-mail server port
|
||||||
:param str folder:
|
:param str folder:
|
||||||
folder to check for e-mails
|
folder to check for e-mails
|
||||||
|
:param int max_msgs:
|
||||||
|
Maximum number of messages. If there are more messages then max_msgs then it
|
||||||
|
will use gradient level equal to 100, otherwise gradient level is equal to
|
||||||
|
``100 * msgs_num / max_msgs``. If not present gradient is not computed.
|
||||||
|
|
||||||
Highlight groups used: ``email_alert``.
|
Highlight groups used: ``email_alert_gradient`` (gradient), ``email_alert``.
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user