-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added mcabber unread buffers widget.
- Loading branch information
Showing
7 changed files
with
109 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- 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 mcabber = require("widgets.vicious.mcabber") | ||
local beautiful = beautiful | ||
local widget_init = widget | ||
local image = image | ||
local mcabber_get_unread_buffers = mcabber_get_unread_buffers | ||
|
||
module("widgets.im") | ||
|
||
local _imicon = nil | ||
local _imwidget = nil | ||
|
||
function icon() | ||
if _imicon == nil then | ||
_imicon = widget_init({ type = "imagebox" }) | ||
_imicon.image = image(beautiful.widget_im) | ||
end | ||
return _imicon | ||
end | ||
|
||
function widget() | ||
if _imwidget == nil then | ||
_imwidget = widget_init({ type = "textbox" }) | ||
vicious.register(_imwidget, mcabber,'$1', 5) | ||
end | ||
return _imwidget | ||
end | ||
|
||
-- vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--------------------------------------------------- | ||
-- Licensed under the GNU General Public License v2 | ||
-- * (c) 2010, Adrian C. <[email protected]> | ||
-- * (c) 2009, Lucas de Vries <[email protected]> | ||
--------------------------------------------------- | ||
|
||
-- {{{ 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 count = {} | ||
|
||
|
||
-- {{{ Checks if mcabber is running | ||
local function mcabber_get_unread_buffers() | ||
local state_file = os.getenv("HOME") .. "/.mcabber/mcabber.state" | ||
local f = io.open(state_file, "r") | ||
local rows = 0 | ||
for _ in f:lines() do | ||
rows = rows + 1 | ||
end | ||
f:close() | ||
return rows | ||
end | ||
-- }}} | ||
|
||
|
||
-- {{{ Counts unread mcabber buffers | ||
local function mcabber_running() | ||
local fd = io.popen("pgrep mcabber") | ||
local pid = fd:read('*a') | ||
fd:close() | ||
|
||
if pid:len() > 0 then | ||
return true | ||
else | ||
return false | ||
end | ||
end | ||
-- }}} | ||
|
||
|
||
-- {{{ Date widget type | ||
local function worker(format, warg) | ||
if not mcabber_running() then | ||
return '<span color="white" bgcolor="grey" weight="bold"> n/a </span>' | ||
end | ||
|
||
local unread = mcabber_get_unread_buffers() | ||
if unread > 0 then | ||
return '<span color="white" bgcolor="red" weight="bold"> ' .. unread .. ' </span>' | ||
else | ||
return '<span color="white" bgcolor="green" weight="bold"> 0 </span>' | ||
end | ||
end | ||
-- }}} | ||
|
||
return setmetatable(count, { __call = function(_, ...) return worker(...) end }) |