29 lines
		
	
	
		
			719 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			719 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
#!/usr/bin/python
 | 
						|
 | 
						|
import imaplib
 | 
						|
import os
 | 
						|
import sys
 | 
						|
 | 
						|
ICON = ""
 | 
						|
CONFIG_FILE = os.path.expanduser("~/.private/config/email")
 | 
						|
 | 
						|
COLOR_HL = "B48EAD"
 | 
						|
COLOR_NONE = "65737E"
 | 
						|
COLOR_ERR = "D08770"
 | 
						|
 | 
						|
n = 0
 | 
						|
if os.path.isfile(CONFIG_FILE):
 | 
						|
    with open(CONFIG_FILE) as fp:
 | 
						|
        for line in fp:
 | 
						|
            addr, pwd = line.strip().split(",")
 | 
						|
            obj = imaplib.IMAP4_SSL('imap.gmail.com', 993)
 | 
						|
            obj.login(addr, pwd)
 | 
						|
            obj.select()
 | 
						|
            n += len(obj.search(None, 'UnSeen')[1][0].split())
 | 
						|
            obj.close()
 | 
						|
            obj.logout()
 | 
						|
    print("%{{F#{}}}{} {}".format(COLOR_HL if n > 0 else COLOR_NONE, ICON, n))
 | 
						|
else:
 | 
						|
    print("%{{F#{}}}{} -".format(COLOR_ERR, ICON))
 | 
						|
    sys.exit(1)
 |