From fef85af5cc0055667ae721f9ce6ad9d66484f60c Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 24 Feb 2007 23:34:14 +0000 Subject: [PATCH] Updated rbox.rb script --- scripts/ruby/rbox.rb | 75 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/scripts/ruby/rbox.rb b/scripts/ruby/rbox.rb index f879304aa..0adabb2a0 100644 --- a/scripts/ruby/rbox.rb +++ b/scripts/ruby/rbox.rb @@ -1,29 +1,84 @@ -# Publié sous license GNU GPL v2 +# Rbox plugin (Rhythmnox control and now playing plugin.) +# Version 0.2 +# Released under GNU GPL v2 # Metallines +# /rbox-help for help def weechat_init - Weechat.register("rbox", "0.1", "", "Affiche ce que rhythmbox joue.") - Weechat.add_command_handler("rbox", "rbox") + Weechat.register("rbox", "0.2", "", "Rhythmbox control and now playing plugin.") + Weechat.add_command_handler("rbox-print", "rbox_print") + Weechat.add_command_handler("rbox-play", "rbox_play") + Weechat.add_command_handler("rbox-pause", "rbox_pause") + Weechat.add_command_handler("rbox-previous", "rbox_previous") + Weechat.add_command_handler("rbox-next", "rbox_next") + Weechat.add_command_handler("rbox-help", "rbox_help") return Weechat::PLUGIN_RC_OK end -def rbox(server, args) - # Si un proocessus qui contient "rhythmbox" est en cours +def rbox_print(server, args) if `ps -C rhythmbox` =~ /rhythmbox/ - # On récupère les informations du morceau joué artiste = `rhythmbox-client --print-playing-format %ta`.chomp titre = `rhythmbox-client --print-playing-format %tt`.chomp album = `rhythmbox-client --print-playing-format %at`.chomp - # On définit les couleurs pour l'affichage dans le salon + couleur_artiste = "C05" couleur_titre = "C10" couleur_album = "C03" couleur_entre = "C14" - # On execute la commande dans le salon + Weechat.command("/me écoute" + " %" + couleur_titre + titre + " %" + couleur_entre + "par" + " %" + couleur_artiste + artiste + " %" + couleur_entre + "de l'album" + " %" + couleur_album + album) - # Sinon on prévient l'utilisateur que Rhythbox ne tourne pas else - Weechat.print("Rhythmbox n'est pas lancé.") + Weechat.print("Rhythmbox isn't running.") end return Weechat::PLUGIN_RC_OK end + +def rbox_play(server, args) + if `ps -C rhythmbox` =~ /rhythmbox/ + `rhythmbox-client --play` + Weechat.print("Start playback.") + else + Weechat.print("Rhythmbox isn't running.") + end + return Weechat::PLUGIN_RC_OK +end + +def rbox_pause(server, args) + if `ps -C rhythmbox` =~ /rhythmbox/ + `rhythmbox-client --pause` + Weechat.print("Pause playback.") + else + Weechat.print("Rhythmbox isn't running.") + end + return Weechat::PLUGIN_RC_OK +end + +def rbox_previous(server, args) + if `ps -C rhythmbox` =~ /rhythmbox/ + `rhythmbox-client --previous` + Weechat.print("Skip to the previous track.") + else + Weechat.print("Rhythmbox isn't running.") + end + return Weechat::PLUGIN_RC_OK +end + +def rbox_next(server, args) + if `ps -C rhythmbox` =~ /rhythmbox/ + `rhythmbox-client --next` + Weechat.print("Skip to the next track.") + else + Weechat.print("Rhythmbox isn't running.") + end + return Weechat::PLUGIN_RC_OK +end + +def rbox_help(server, args) + Weechat.print("/rbox-play -> Start playback") + Weechat.print("/rbox-pause -> Pause playback") + Weechat.print("/rbox-previous -> Skip to previous track") + Weechat.print("/rbox-next -> Skip to next track") + Weechat.print("/rbox-print -> Print which song rhythmbox is playing in current channel") + Weechat.print("/robix-help -> Display this help") + return Weechat::PLUGIN_RC_OK +end