diff options
Diffstat (limited to 'EmailWidget')
-rw-r--r-- | EmailWidget/README.md | 26 | ||||
-rw-r--r-- | EmailWidget/email.lua | 40 | ||||
-rw-r--r-- | EmailWidget/emailWidgetScrnsht.png | bin | 875 -> 0 bytes | |||
-rw-r--r-- | EmailWidget/emailWidgetScrnsht2.png | bin | 63784 -> 0 bytes | |||
-rw-r--r-- | EmailWidget/getUnreadEmails.py | 39 | ||||
-rw-r--r-- | EmailWidget/getUnreadEmailsNum.py | 16 | ||||
-rw-r--r-- | EmailWidget/mail.png | bin | 7465 -> 0 bytes | |||
-rw-r--r-- | EmailWidget/mailWathcer.py | 100 |
8 files changed, 0 insertions, 221 deletions
diff --git a/EmailWidget/README.md b/EmailWidget/README.md deleted file mode 100644 index 6f204ca..0000000 --- a/EmailWidget/README.md +++ /dev/null @@ -1,26 +0,0 @@ -This widget consists of an icon with counter which shows number of unread emails: ![email icon](./emailWidgetScrnsht.png) -and a popup message which appears when mouse hovers over an icon: ![email popup](./emailWidgetScrnsht2.png) - -## Installation - -To install it either clone [EmailWidget](https://github.com/streetturtle/AwesomeWM/tree/master/EmailWidget) project under `~/.config/awesome/` or download a .zip archive and unzip it there. - -After provide your credentials in python scripts so that they could connect to server and add following lines in your **rc.lua** file: - -```lua -require("email") -... -right_layout:add(emailWidget_icon) -right_layout:add(emailWidget_counter) -``` - -## How it works - -This widget uses the output of two python scripts, first is called every 5 seconds - it returns number of unread emails and second is called when mouse hovers over an icon and displays content of those emails. For both of them you'll need to provide your credentials and imap server. For testing they can simply be called from console: - -``` bash -python ~/.config/awesome/email/countUnreadEmails.py -python ~/.config/awesome/email/readEmails.py -``` - -Note that getting number of unread emails could take some time, so instead of `pread` or `spawn_with_shell` functions I use DBus, you can read more about it in [this]({{site.url}}/2015/09/fix-awesome-freezes) post. diff --git a/EmailWidget/email.lua b/EmailWidget/email.lua deleted file mode 100644 index 3f486cf..0000000 --- a/EmailWidget/email.lua +++ /dev/null @@ -1,40 +0,0 @@ -local wibox = require("wibox") -local awful = require("awful") -local naughty = require("naughty") - -function showEmailWidgetPopup() - local save_offset = offset - local popuptext = "test" - naughty.notify({ - title = "Unread emails", - text = awful.util.pread("python /home/username/.config/awesome/getUnreadEmails.py"), - timeout = 10, - width = 300, - fg = "#ffffff", - bg = "#333333aa", - }) -end - --- Icon which shows unread emails when hover -emailIcon = wibox.widget.imagebox() -emailIcon:set_image("/home/username/.config/awesome/mail.png") -emailIcon:connect_signal("mouse::enter", function() showEmailWidgetPopup() end) - -dbus.request_name("session", "ru.console.df") -dbus.add_match("session", "interface='ru.console.df', member='fsValue' " ) -dbus.connect_signal("ru.console.df", - function (...) - local data = {...} - local dbustext = data[2] - emailCount:set_text(dbustext) - end) - --- Counter which shows number of unread emails -emailCount = wibox.widget.textbox() - -emailCountTimer = timer ({timeout = 5}) -emailCountTimer:connect_signal ("timeout", - function () - awful.util.spawn_with_shell("dbus-send --session --dest=org.naquadah.awesome.awful /ru/console/df ru.console.df.fsValue string:$(python /home/username/.config/awesome/getUnreadEmailsNum.py)" ) - end) -emailCountTimer:start() diff --git a/EmailWidget/emailWidgetScrnsht.png b/EmailWidget/emailWidgetScrnsht.png Binary files differdeleted file mode 100644 index 07b69ce..0000000 --- a/EmailWidget/emailWidgetScrnsht.png +++ /dev/null diff --git a/EmailWidget/emailWidgetScrnsht2.png b/EmailWidget/emailWidgetScrnsht2.png Binary files differdeleted file mode 100644 index e2acc0c..0000000 --- a/EmailWidget/emailWidgetScrnsht2.png +++ /dev/null diff --git a/EmailWidget/getUnreadEmails.py b/EmailWidget/getUnreadEmails.py deleted file mode 100644 index 8b4714a..0000000 --- a/EmailWidget/getUnreadEmails.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/python - -import imaplib -import email -import datetime - -def process_mailbox(M): - rv, data = M.search(None, "UNSEEN") - if rv != 'OK': - print "No messages found!" - return - - for num in data[0].split(): - # rv, data = M.fetch(num, '(RFC822)') # mark us read - rv, data = M.fetch(num, '(BODY.PEEK[])') # don't mark us read - if rv != 'OK': - print "ERROR getting message", num - return - - msg = email.message_from_string(data[0][1]) - print 'From:', msg['From'] - print 'Subject: %s' % (msg['Subject']) - date_tuple = email.utils.parsedate_tz(msg['Date']) - if date_tuple: - local_date = datetime.datetime.fromtimestamp( - email.utils.mktime_tz(date_tuple)) - print "Local Date:", local_date.strftime("%a, %d %b %Y %H:%M:%S") - print - -M=imaplib.IMAP4_SSL("imap.whatever.com", 993) -M.login("username","password") - -rv, data = M.select("INBOX") -if rv == 'OK': - process_mailbox(M) - M.close() - -M.logout() - diff --git a/EmailWidget/getUnreadEmailsNum.py b/EmailWidget/getUnreadEmailsNum.py deleted file mode 100644 index 5599f2e..0000000 --- a/EmailWidget/getUnreadEmailsNum.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python - -import imaplib -import email - -M=imaplib.IMAP4_SSL("imap.whatever.com", 993) -M.login("username","password") - -status, counts = M.status("INBOX","(MESSAGES UNSEEN)") - -if status == "OK": - unread = int(counts[0].split()[4][:-1]) -else: - unread = "N/A" - -print(unread) diff --git a/EmailWidget/mail.png b/EmailWidget/mail.png Binary files differdeleted file mode 100644 index 1df6fae..0000000 --- a/EmailWidget/mail.png +++ /dev/null diff --git a/EmailWidget/mailWathcer.py b/EmailWidget/mailWathcer.py deleted file mode 100644 index b116521..0000000 --- a/EmailWidget/mailWathcer.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/python - -import imaplib -import email -import datetime - -def process_mailbox(M): - rv, data = M.search(None, "UNSEEN") - if rv != 'OK': - print "No messages found!" - return - - for num in data[0].split(): - # rv, data = M.fetch(num, '(RFC822)') - rv, data = M.fetch(num, '(BODY.PEEK[])') - if rv != 'OK': - print "ERROR getting message", num - return - - msg = email.message_from_string(data[0][1]) - print 'From:', msg['From'] - print 'Subject: %s' % (msg['Subject']) - print 'Raw Date:', msg['Date'] - date_tuple = email.utils.parsedate_tz(msg['Date']) - if date_tuple: - local_date = datetime.datetime.fromtimestamp( - email.utils.mktime_tz(date_tuple)) - print "Local Date:", \ - local_date.strftime("%a, %d %b %Y %H:%M:%S") - - -M=imaplib.IMAP4_SSL("imap.cern.ch", 993) -M.login("pavel.makhov@cern.ch","cB#h8g!2n") - -# status, counts = M.status("INBOX","(MESSAGES UNSEEN)") -# # status, counts = M.status("INBOX/!Edh-team","(MESSAGES UNSEEN)") - -# unread = counts[0].split()[4][:-1] - -# # print(status) -# print(unread) -rv, data = M.select("INBOX") -if rv == 'OK': - print "Processing mailbox...\n" - process_mailbox(M) # ... do something with emails, see below ... - M.close() -M.logout() - - -# M.select("INBOX") -# status, response = M.search('INBOX', '(UNSEEN)') - -# unread_msg_nums = response[0].split() - -# # Print the count of all unread messages -# print len(unread_msg_nums) - -# print 'HEADER:' -# typ, msg_data = M.fetch('1', '(BODY.PEEK[HEADER])') -# for response_part in msg_data: -# if isinstance(response_part, tuple): -# print response_part[1] - - - - -# da = [] -# # for e_id in unread_msg_nums: -# _, response = M.fetch(1, '(BODY.PEEK[TEXT])') -# # _, response = M.fetch(e_id, '(UID BODY[TEXT])') -# da.append(response[0][1]) -# print da - - - -# typ, data = M.select ("INBOX/!Edh-team") - -# status, response = imap.search('INBOX', '(UNSEEN)') - -# unread_msg_num = response[0].split() - -# Print the count of all unread messages - -#print typ -#print data - -# for num in data[0].split(): -# typ, data = M.fetch(num, '(RFC822)') -# print 'Message %s\n%s\n' % (num, data[0][1]) - -# for response_part in data: -# if isinstance(response_part, tuple): -# msg = email.message_from_string(response_part[1]) -# for header in [ 'subject', 'to', 'from' ]: -# print '%-8s: %s' % (header.upper(), msg[header]) - - - -# M.close() -# M.logout() |