From c4826fd21340d34e3592b0c8ca24fc068e52c6ef Mon Sep 17 00:00:00 2001 From: streetturtle Date: Mon, 30 Jan 2017 21:38:50 -0500 Subject: new widgets added --- email-widget/email.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 email-widget/email.lua (limited to 'email-widget/email.lua') diff --git a/email-widget/email.lua b/email-widget/email.lua new file mode 100644 index 0000000..22a7b6d --- /dev/null +++ b/email-widget/email.lua @@ -0,0 +1,42 @@ +local wibox = require("wibox") +local awful = require("awful") +local naughty = require("naughty") +local watch = require("awful.widget.watch") + +local path_to_icons = "/usr/share/icons/Arc-Icons/actions/22/" + +email_widget = wibox.widget.textbox() +email_widget:set_font('Play 9') + +email_icon = wibox.widget.imagebox() +email_icon:set_image(path_to_icons .. "/mail-mark-new.png") + +watch( + "python /home//.config/awesome/email/count_unread_emails.py", 20, + function(widget, stdout, stderr, exitreason, exitcode) + local unread_emails_num = tonumber(stdout) + if (unread_emails_num > 0) then + email_icon:set_image(path_to_icons .. "/mail-mark-unread.png") + email_widget:set_text(stdout) + elseif (unread_emails_num == 0) then + email_icon:set_image(path_to_icons .. "/mail-message-new.png") + email_widget:set_text("") + end + end +) + + +function show_emails() + awful.spawn.easy_async([[bash -c 'python /home//.config/awesome/email/read_unread_emails.py']], + function(stdout, stderr, reason, exit_code) + naughty.notify{ + text = stdout, + title = "Unread Emails", + timeout = 5, hover_timeout = 0.5, + width = 400, + } + end + ) +end + +email_icon:connect_signal("mouse::enter", function() show_emails() end) \ No newline at end of file -- cgit v1.2.3