вторник, 18 августа 2009 г.

Number of unread mcabber messages in awesome panel

After I started using awesome wm and mcabber as jabber client. I found many solutions to notify new messages: pop-up messages, sound notification and many other things. Any of them did not approach me. I use awesome on my netbook, and sound always switched off. Pop-up windows just blocked the working space necessary to me. As a result - has written small widget for awesome.

First. We need to uncomment lines in mcabber configuration file.

vim ~/.mcabber/mcabberrc

Following lines are necessary to use:
set logging = 1
set logging_dir = ~/.mcabber/histo
set statefile = ~/.mcabber/mcabber.state
Attention: Check folder grants. Directory ~/.mcabber/histo should exist!

Next we need small "parser" script. And here it is:
#!/bin/zsh

MCABBER_NO=`cat /home/bosheee/.mcabber/mcabber.state &>/dev/null|wc -l`

[[ "$MCABBER_NO" -gt "0" ]] && echo "$MCABBER_NO Mess"

exit 0
Sorry for zsh :-[ Save them in home dir, and make it executable (+x).

Add this function somewhere below wibox.
function mcabber_mess()
local filedescriptor = io.popen('~/mcabber_message_num.sh')
local value = nil
if filedescriptor ~= nil then
value = filedescriptor:read()
end
filedescriptor:close()
if value == nil then
return '0 Mess'
else
return value
end
end

getmcabbermessnum = widget({
type = 'textbox',
name = 'getmcabbermessnum',
align = 'right'})

wicked.register(
getmcabbermessnum,
mcabber_mess,
" $1 ")
Also add hook after hourse hook:
awful.hooks.timer.register(3, function() getmcabbermessnum.text = mcabber_mess() end)
Add getmcabbermessnum in your mywibox[s].widget array.

All done! Restart awesome and enjoy it. I will answer any questions in comments.



P.S thanks a lot people in IRC chanel, and my friend for help =)

1 комментарий:

  1. Этот комментарий был удален администратором блога.

    ОтветитьУдалить