summaryrefslogtreecommitdiff
path: root/scripts/python/awl.py
blob: cf8bfd43455e6d79f233b8e24f46379ae215a8f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
  This script shows buffer list in infobar. Nothing more.
  It's inspired by `awl.pl` irssi script, but is less advanced. :)

  The script is in the public domain.
  Leonid Evdokimov (weechat at darkk dot net dot ru)
  http://darkk.net.ru/weechat/awl.py
"""

#######################################################################

import weechat

version = "0.1"
# how often to refresh infobar
timer_interval = 1

def cleanup():
    weechat.remove_infobar(-1)
    return weechat.PLUGIN_RC_OK

def update_channels():
    the_string = [];
    buffers = weechat.get_buffer_info()
    if buffers != None:
        for index, buffer in buffers.iteritems():
            #**** info for buffer no 8 ****
            # > log_filename, notify_level, server, num_displayed, type, channel
            if len(buffer['channel']):
                name = buffer['channel']
            elif len(buffer['server']):
                name = "[" + buffer['server'] + "]"
            else:
                name = "?"
            the_string.append("%i:%s" % (index, name))
    the_string = " ".join(the_string)
    weechat.remove_infobar(-1)
    weechat.print_infobar(0, the_string);

def on_timer():
    update_channels()
    return weechat.PLUGIN_RC_OK

if weechat.register("awl", version, "cleanup", "bufferlist in infobar"):
    #message handlers are called __before__ buflist is changed, so we don't use them
    weechat.add_timer_handler(timer_interval, "on_timer")
    update_channels()