summaryrefslogtreecommitdiff
path: root/scripts/perl/xmms.pl
blob: 92e89fd663239a4dbabe5df38259088a883b90c0 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#####################################################################
# xmms perl script for weechat                                      #
#                                                                   #
# Displays some useless xmms-infopipe values                        #
# (c) 2006 by C�dric Chalier <llinkz@gmail.com>                     # 
#                                                                   #
# This program is free software; you can redistribute it and/or     #
# modify it under the terms of the GNU General Public License       #
# as published by the Free Software Foundation; either version 2    #
# of the License, or (at your option) any later version.            #
#                                                                   #
# This program is distributed in the hope that it will be useful,   #
# but WITHOUT ANY WARRANTY; without even the implied warranty of    #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     #
# GNU General Public License for more details.                      #
#                                                                   #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software       #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,        #
# MA  02110-1301, USA.                                              #
#                                                                   #
#####################################################################
#  db[x] variables are:                                             #
# -----------------------------------------------------------       #
# | 0 | XMMS protocol version      |  7 | uSecTime                  #
# | 1 | InfoPipe Plugin version    |  8 | Time                      #
# | 2 | Status                     |  9 | Current bitrate           #
# | 3 | Tunes in playlist          | 10 | Samping Frequency         #
# | 4 | Currently playing          | 11 | Channels                  #
# | 5 | uSecPosition               | 12 | Title                     #
# | 6 | Position                   | 13 | File                      #
#                                                                   #
#####################################################################

weechat::register ("xmms", "1.1", "", "xmms info script (usage: /xmms)");
weechat::add_command_handler ("xmms", xmmsinfo);

sub xmmsinfo {
    if (! -e "/tmp/xmms-info")
    {} 
    else 
    {
        open (fi, "/tmp/xmms-info");
        @db2 = <fi>;
        foreach $l (0 .. 14)
        {
            ($c,$tmp) = split(": " ,$db2[$l]);
            chomp($tmp);
            push @db,$tmp;
        }
    }
    if (($db[7]!=-1) && ($db[7]!=0)) 
    {
        weechat::command("/me np: $db[12]");
    }
    else
    {
        weechat::command("/me np: $db[12] ($db[13])");
    }
    @db = ();
    @db2 = ();
    close (fi);
}
# $id: xmms-weechat.pl,v 1.1 2006/05/23 00:50:10 linkz Exp $