#!/usr/bin/perl -w # Rhythmbox XChat Announcer 0.2 # (c) Copyright 2006 - Tim Denholm # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use POSIX qw(strftime); $script_name = "Rhythmbox XChat Announcer"; $script_version = "0.2"; $script_description = "Announces the current playing song information from Rhythmbox in XChat."; $rhythmbox_version = `rhythmbox --version`; $rhythmbox_version =~ s/Gnome\srhythmbox\s//; chop $rhythmbox_version; IRC::register($script_name,$script_version,$script_description,""); IRC::print("Loaded \002".$script_name."\002:"); IRC::print("Use \002/rb_help\002 to display a list of commands."); IRC::add_command_handler("mp3","rb_announce"); IRC::add_command_handler("rb_next","rb_next"); IRC::add_command_handler("rb_prev","rb_prev"); IRC::add_command_handler("rb_play","rb_play"); IRC::add_command_handler("rb_pause","rb_pause"); IRC::add_command_handler("rb_version","rb_version"); IRC::add_command_handler("rb_help","rb_help"); sub rb_announce { if (`ps -C rhythmbox` =~ /rhythmbox/) { # Get current playing song information. $song_info = `rhythmbox-client --print-playing-format %ta\\ -\\ %at\\ -\\ %tt\\ -\\ "(%td seg)"`; chop $song_info; IRC::command("/me escucha: ".$song_info); } else { IRC::print("Rhythmbox is not currently running."); } return 1; } sub rb_next { # Skip to the next track. eval `rhythmbox-client --next`; IRC::print("Skipped to next track."); return 1; } sub rb_prev { # Skip to the previous track. eval `rhythmbox-client --previous`; IRC::print("Skipped to previous track."); return 1; } sub rb_play { # Start playback. eval `rhythmbox-client --play`; IRC::print("Started playback."); return 1; } sub rb_pause { # Pause playback. eval `rhythmbox-client --pause`; IRC::print("Paused playback."); return 1; } sub rb_version { # Display version information to a channel. IRC::command("/me is using ".$script_name." ".$script_version." with Rhythmbox ".$rhythmbox_version." and XChat ".IRC::get_info(0)); return 1; } sub rb_help { # Display help screen. IRC::print("\002\037".$script_name." Help:\037\002"); IRC::print(" \002About:\002"); IRC::print(" * Author: Tim Denholm "); IRC::print(" * URL: http://tim.codestorm.net/projects/xchat-rhythmbox/"); IRC::print(" * Script Version: ".$script_version); IRC::print(" * Rhythmbox Version: ".$rhythmbox_version); IRC::print(" * XChat Version: ".IRC::get_info(0)); IRC::print(" \002Commands:\002"); IRC::print(" * /rb_announce - Display the current song playing to a channel."); IRC::print(" * /rb_next - Skip to the next track."); IRC::print(" * /rb_prev - Skip to the previous track."); IRC::print(" * /rb_play - Start playback."); IRC::print(" * /rb_pause - Pause playback."); IRC::print(" * /rb_version - Display version information for the script, Rhythmbox and XChat to a channel."); IRC::print(" * /rb_help - Display this help screen."); return 1; }