본문 바로가기

Com/Etc..

Gmail geektool script

Geektool용 Gmail 카운트 스크립트

인터넷에서 구한건데 출처를 잊어버려서 백업 겸으로 올림

#!/usr/bin/env python -tt
import sys
import curses
import imaplib
import warnings

def main():
  imap_server = imaplib.IMAP4_SSL("imap.gmail.com",993)
  imap_server.login('Gmail ID', 'password')
  imap_server.select('INBOX')
  status, response = imap_server.status('INBOX', "(UNSEEN)")
  unreadcount = int(response[0].split()[2].strip(').,]'))
  print unreadcount
  imap_server.logout()

# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
  main()


Gmail ID에 본인의 메일 아이디, Password에 비밀번호를 입력하고 적용.