diff --git a/rc.lua b/rc.lua
index c9ebef7..2cdb315 100644
--- a/rc.lua
+++ b/rc.lua
@@ -40,6 +40,7 @@ widgets.net = require("widgets.net")
widgets.spacer = require("widgets.spacer")
widgets.volume = require("widgets.volume")
widgets.im = require("widgets.im")
+widgets.gmail = require("widgets.gmail")
-- }}}
-- {{{ Variable definitions
diff --git a/rc/wibox.lua b/rc/wibox.lua
index 152a495..d312db9 100644
--- a/rc/wibox.lua
+++ b/rc/wibox.lua
@@ -28,9 +28,6 @@ for s = 1, screen.count() do
mylayoutbox[s],
widgets.clock.widget(),
s == 1 and widget({ type = "systray" }) or nil,
- widgets.spacer.widget(),
- widgets.im.widget(),
- widgets.im.icon(),
-- widgets.net.widget(),
utils.system.hasbattery() and widgets.spacer.widget() or nil,
utils.system.hasbattery() and widgets.bat.widget(wide) or nil,
@@ -49,6 +46,12 @@ for s = 1, screen.count() do
widgets.spacer.widget(),
widgets.volume.widget(),
widgets.volume.icon(),
+ widgets.spacer.widget(),
+ widgets.gmail.widget(),
+ widgets.gmail.icon(),
+ widgets.spacer.widget(),
+ widgets.im.widget(),
+ widgets.im.icon(),
layout = awful.widget.layout.horizontal.rightleft
}
end
diff --git a/themes/gits/icons/gmail.png b/themes/gits/icons/gmail.png
new file mode 100644
index 0000000..31ed0b1
Binary files /dev/null and b/themes/gits/icons/gmail.png differ
diff --git a/themes/gits/theme.lua b/themes/gits/theme.lua
index 01c1a7f..4ebdadb 100644
--- a/themes/gits/theme.lua
+++ b/themes/gits/theme.lua
@@ -162,6 +162,7 @@ theme.widget_mpd_play = themedir.."/icons/mpd_play.png"
theme.widget_mpd_pause = themedir.."/icons/mpd_pause.png"
theme.widget_mpd_stop = themedir.."/icons/mpd_stop.png"
theme.widget_im = themedir.."/icons/im.png"
+theme.widget_gmail = themedir.."/icons/gmail.png"
-- }}}
return theme
diff --git a/widgets/gmail.lua b/widgets/gmail.lua
new file mode 100644
index 0000000..8b26229
--- /dev/null
+++ b/widgets/gmail.lua
@@ -0,0 +1,56 @@
+-- File system size widget definition
+-- Module variables are :
+--
+-- widget : the wiget itself
+-- icon : the associated widget icon
+--
+-- Note that he theme should have widget_disk attribute set
+
+local vicious = require("vicious")
+local awful = require("awful")
+local blingbling = require("blingbling")
+local gmail = require("widgets.vicious.gmail")
+local beautiful = beautiful
+local widget_init = widget
+local image = image
+
+module("widgets.gmail")
+
+local _gmailicon = nil
+local _gmailwidget = nil
+local _gmailenabled = true
+
+
+local function gmail_toggle()
+ if _gmailenabled then
+ vicious.unregister(_gmailwidget, true)
+ _gmailwidget.text = ' dis '
+ else
+ vicious.activate(_gmailwidget)
+ end
+ _gmailenabled = not _gmailenabled
+end
+
+
+function icon()
+ if _gmailicon == nil then
+ _gmailicon = widget_init({ type = "imagebox" })
+ _gmailicon.image = image(beautiful.widget_gmail)
+ end
+ return _gmailicon
+end
+
+
+function widget()
+ if _gmailwidget == nil then
+ _gmailwidget = widget_init({ type = "textbox" })
+ _gmailwidget:buttons(awful.util.table.join(
+ awful.button({ }, 1, function ()
+ gmail_toggle()
+ end)))
+ vicious.register(_gmailwidget, gmail,'$1', 30)
+ end
+ return _gmailwidget
+end
+
+-- vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/widgets/im.lua b/widgets/im.lua
index 05008de..18fdee9 100644
--- a/widgets/im.lua
+++ b/widgets/im.lua
@@ -19,6 +19,19 @@ module("widgets.im")
local _imicon = nil
local _imwidget = nil
+local _imenabled = true
+
+
+local function im_toggle()
+ if _imenabled then
+ vicious.unregister(_imwidget, true)
+ _imwidget.text = ' dis '
+ else
+ vicious.activate(_imwidget)
+ end
+ _imenabled = not _imenabled
+end
+
function icon()
if _imicon == nil then
@@ -28,9 +41,14 @@ function icon()
return _imicon
end
+
function widget()
if _imwidget == nil then
_imwidget = widget_init({ type = "textbox" })
+ _imwidget:buttons(awful.util.table.join(
+ awful.button({ }, 1, function ()
+ im_toggle()
+ end)))
vicious.register(_imwidget, mcabber,'$1', 5)
end
return _imwidget
diff --git a/widgets/vicious/gmail.lua b/widgets/vicious/gmail.lua
new file mode 100644
index 0000000..73eae91
--- /dev/null
+++ b/widgets/vicious/gmail.lua
@@ -0,0 +1,56 @@
+---------------------------------------------------
+-- Licensed under the GNU General Public License v2
+-- * (c) 2010, Adrian C.
+-- * (c) 2009, Lucas de Vries
+---------------------------------------------------
+
+-- {{{ Grab environment
+local os = { getenv=os.getenv }
+local io = { open=io.open, popen=io.popen }
+local print = print
+-- }}}
+
+-- Count: provides mcabber unread buffers count
+local rss = "https://mail.google.com/mail/feed/atom"
+local count = {}
+
+
+-- {{{ Checks if mcabber is running
+local function gmail_get_unread_messages()
+ local unread = 0
+
+ -- Get info from the Gmail atom feed
+ local f = io.popen("curl --connect-timeout 1 -m 3 -fsn " .. rss)
+
+ -- Could be huge don't read it all at once, info we are after is at the top
+ for line in f:lines() do
+ count = string.match(line, "([%d]+)")
+ if count then
+ unread = tonumber(count)
+ break
+ end
+ end
+ f:close()
+ return unread
+end
+-- }}}
+
+
+-- {{{ Date widget type
+local function worker(format, warg)
+-- if not mcabber_running() then
+-- return ' n/a '
+-- end
+
+ local unread = gmail_get_unread_messages()
+ if unread > 0 then
+ return ' ' .. unread .. ' '
+ else
+ return ' 0 '
+ end
+end
+-- }}}
+
+return setmetatable(count, { __call = function(_, ...) return worker(...) end })
+
+-- vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4