Merge pull request #31 from talwrii/master
mbox -- mail backend to deal with mbox files as used by procmail, for ex...
This commit is contained in:
commit
87a8ae1177
25
i3pystatus/mail/mbox.py
Normal file
25
i3pystatus/mail/mbox.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from i3pystatus.mail import Backend
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
class MboxMail(Backend):
|
||||||
|
"""
|
||||||
|
Checks for local mail in mbox
|
||||||
|
"""
|
||||||
|
|
||||||
|
settings = ()
|
||||||
|
required = ()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unread(self):
|
||||||
|
p = subprocess.Popen(['messages.mailutils'], stdout=subprocess.PIPE)
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
stdout = stdout.decode('utf8')
|
||||||
|
assert p.returncode == 0, "messages.mailutils returned non-zero return code"
|
||||||
|
s_stuff, message_number = stdout.strip().rsplit(':', 1)
|
||||||
|
return int(message_number.strip())
|
||||||
|
|
||||||
|
Backend = MboxMail
|
Loading…
Reference in New Issue
Block a user