Skip to content

Commit

Permalink
Enhanced mcabber ineractions.
Browse files Browse the repository at this point in the history
  • Loading branch information
geektophe committed Oct 18, 2013
1 parent b454b79 commit 804d3c0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 36 deletions.
Binary file added icons/im/notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/im/problem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/im/recovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 33 additions & 35 deletions rc/im.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,58 +33,56 @@ naughty.config.presets.error = {
}


function mcabber_event_hook(kind, direction, jid, msg)
function mcabber_event_hook(kind, arg, jid, msg)
if kind == "MSG" then
if direction == "IN" or direction == "MUC" then
if arg == "IN" or arg == "MUC" then
local filehandle = io.open(msg)
local txt = filehandle:read("*all")
filehandle:close()
awful.util.spawn("rm "..msg)
if direction == "MUC" and txt:match("^<" .. muc_nick .. ">") then
os.remove(msg)
if arg == "MUC" and txt:match("^<" .. muc_nick .. ">") then
return
end

if jid == "[email protected]" and string.match(msg, "^PROBLEM:") then
preset = naughty.config.presets.critical
else
preset = naughty.config.presets.normal
preset = naughty.config.presets.normal
icon = "person"

if string.match(jid, "[email protected]") then
if string.match(txt, "^PROBLEM:") then
icon = "problem"
txt = string.gsub(txt, "^PROBLEM: ", "")
elseif string.match(txt, "^RECOVERY:") then
icon = "recovery"
txt = string.gsub(txt, "^RECOVERY: ", "")
elseif string.match(txt, "^ACKNOWLEDGEMENT: ") then
icon = "notification"
txt = string.gsub(txt, "^ACKNOWLEDGEMENT: ", "")
end
elseif string.match(jid, "conference.dailymotion.com") then
icon = "chat"
end

naughty.notify{
icon = "chat_msg_recv",
icon = icon,
text = awful.util.escape(txt),
title = jid,
timeout = 30,
preset = preset
}
end
-- Disabled connect/disconnect notifications.
elseif kind == "STATUS" and false then
local mapping = {
[ "O" ] = "online",
[ "F" ] = "chat",
[ "A" ] = "away",
[ "N" ] = "xa",
[ "D" ] = "dnd",
[ "I" ] = "invisible",
[ "_" ] = "offline",
[ "?" ] = "error",
[ "X" ] = "requested"
}
local status = mapping[direction]
local iconstatus = status
if not status then
status = "error"
end
if jid:match("icq") then
iconstatus = "icq/" .. status
end
naughty.notify{
preset = naughty.config.presets[status],
text = jid,
icon = iconstatus
}
end
end


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

-- vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
2 changes: 1 addition & 1 deletion rc/naughty.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Naughty configuration

naughty.config.default_preset = {
timeout = 45,
timeout = 30,
margin = 4,
gap = 1,
}
Expand Down

0 comments on commit 804d3c0

Please sign in to comment.