Roadmap

Attachment 'irssi_audacious_v1.0.2.pl'

Download

   1 use strict;
   2 use vars qw($VERSION %IRSSI);
   3 # Audacious Irssi Script v1.0.2
   4 #
   5 # Change Log:
   6 # v1.0.2:
   7 #	- The script now handles warning support if you got audacious not running
   8 #	- Added track number, current time elapse and total track time
   9 #	- Added Stop functionality
  10 # v1.0.1:
  11 #	- Added ability to autonotify the channel after skipping a song (optional)
  12 #	- Added Skip/Play/Pause/Resume calls
  13 #
  14 # How To Use?
  15 # Copy your script into ~/.irssi/scripts/ directory
  16 # Load your script with /script load audacious in your Irssi Client
  17 # Type /usage in any channel for script commands
  18 # For autoload insert your script into ~/.irssi/scripts/autorun/ directory
  19 # Even better would be if you placed them in ~/.irssi/scripts/ and created symlinks in autorun directory
  20 
  21 use Irssi;
  22 $VERSION = '1.0.2';
  23 %IRSSI = (
  24    authors	=>   "compengi",
  25    contact	=>   "IRC: FreeNode Network, #Ubuntu-LB",
  26    name		=>   "Audacious Irssi Script",
  27    description	=>   "Displays Current Song".
  28 		     "Skips/Plays/Pauses/Stops/Resumes Songs".
  29 		     "Displays Script/Player's Current Version",
  30    license      =>   "Public Domain",
  31 );
  32 
  33 sub cmd_song {
  34    my ($data, $server, $witem) = @_;
  35 	# Get current song information.
  36   if ($witem && ($witem->{type} eq "CHANNEL")) {
  37     if (`ps -C audacious` =~ /audacious/) {
  38       my $position = `audtool --playlist-position`;
  39       my $song = `audtool --current-song`;
  40       my $current = `audtool --current-song-output-length`;
  41       my $total = `audtool --current-song-length`;
  42       chomp($song);
  43       chomp($position);
  44       chomp($current);
  45       chomp($total);
  46 
  47       $witem->command("/me is listening to: #$position $song ($current/$total)");
  48    }
  49    else {
  50       $witem->print("Audacious is not currently running.");
  51     }
  52    return 1;
  53   }
  54 }
  55 
  56 sub cmd_next {
  57    my ($data, $server, $witem) = @_;
  58 	# Skip to the next track.
  59    if ($witem && ($witem->{type} eq "CHANNEL")) {
  60     if (`ps -C audacious` =~ /audacious/) {
  61       my $playing = `audtool --playlist-advance`;
  62 	# Uncomment those lines if you want the script to
  63 	# automatically notify the channel to what song you have skipped
  64 #     my $position = `audtool --playlist-position`;
  65 #     my $song = `audtool --current-song`;
  66 #     chomp($position);
  67 #     chomp($song);
  68 
  69       $witem->print("Skipped to next track.");
  70 #     $witem->command("/me has skipped to: #$position $song");
  71    }
  72    else {
  73       $witem->print("Can't skip to next track. Check your Audacious.");
  74     }
  75    return 1;
  76    }
  77 }
  78 
  79 sub cmd_previous {
  80    my ($data, $server, $witem) = @_;
  81 	# Skip to the previous track.
  82    if ($witem && ($witem->{type} eq "CHANNEL")) {
  83     if (`ps -C audacious` =~ /audacious/) {
  84       my $playing = `audtool --playlist-reverse`;
  85 	# Uncomment those lines if you want the script to
  86 	# automatically notify the channel to what song you have skipped
  87 #     my $position = `audtool --playlist-position`;
  88 #     my $song = `audtool --current-song`;
  89 #     chomp($position);
  90 #     chomp($song);
  91 
  92       $witem->print("Skipped to previous track.");
  93 #     $witem->command("/me has skipped to: #$position $song");
  94    }
  95    else {
  96       $witem->print("Can't skip to next track. Check your Audacious.");
  97     }
  98    return 1;
  99    }
 100 }
 101 
 102 sub cmd_playing {
 103    my ($data, $server, $witem) = @_;
 104 	# Start playback.
 105    if ($witem && ($witem->{type} eq "CHANNEL")) {
 106     if (`ps -C audacious` =~ /audacious/) {
 107       my $playing = `audtool --playback-play`;
 108 
 109       $witem->print("Started playback.");
 110    }
 111    else {
 112       $witem->print("Playback can't be performed now.");
 113     }
 114    return 1;
 115    }
 116 }
 117 
 118 sub cmd_pause {
 119    my ($data, $server, $witem) = @_;
 120 	# Pause playback.
 121    if ($witem && ($witem->{type} eq "CHANNEL")) {
 122     if (`ps -C audacious` =~ /audacious/) {
 123       my $pause = `audtool --playback-pause`;
 124 
 125       $witem->print("Paused playback.");
 126    }
 127    else {
 128       $witem->print("Pause can be only performed when Audacious is running.");
 129     }
 130    return 1;
 131    }
 132 }
 133 
 134 sub cmd_stop {
 135    my ($data, $server, $witem) = @_;
 136 	# Pause playback.
 137    if ($witem && ($witem->{type} eq "CHANNEL")) {
 138     if (`ps -C audacious` =~ /audacious/) {
 139       my $pause = `audtool --playback-stop`;
 140 
 141       $witem->print("Stopped playback.");
 142    }
 143    else {
 144       $witem->print("This way you can't start Audacious.");
 145     }
 146    return 1;
 147    }
 148 }
 149 
 150 sub cmd_version {
 151    my ($data, $server, $witem) = @_;
 152 	# Displays version information to the channel.
 153    if ($witem && ($witem->{type} eq "CHANNEL")) {
 154       my $audacious_version = `audacious --version`;
 155       chop $audacious_version;
 156 
 157       $witem->command("/me is running: Audacious Irssi Script v$VERSION with ".$audacious_version);
 158    }
 159 }
 160 
 161 sub cmd_usage {
 162    my ($data, $server, $witem) = @_;
 163 	# Displays usage screen.
 164       Irssi::print("* /song - Display the current song playing to a channel.");
 165       Irssi::print("* /next     - Start playback.");
 166       Irssi::print("* /previous     - Start playback.");
 167       Irssi::print("* /play     - Start playback.");
 168       Irssi::print("* /pause    - Pause playback.");
 169       Irssi::print("* /stop    - Stop playback.");
 170       Irssi::print("* /about  - Displays version of the script and audacious in the channel.");
 171 }
 172 
 173 Irssi::command_bind ('song', 'cmd_song');
 174 Irssi::command_bind ('next', 'cmd_next');
 175 Irssi::command_bind ('previous', 'cmd_previous');
 176 Irssi::command_bind ('play', 'cmd_playing');
 177 Irssi::command_bind ('pause', 'cmd_pause');
 178 Irssi::command_bind ('stop', 'cmd_stop');
 179 Irssi::command_bind ('usage', 'cmd_usage');
 180 Irssi::command_bind ('about', 'cmd_version');

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2008-08-12 20:15:33, 5.4 KB) [[attachment:irssi_audacious_v1.0.2.pl]]
  • [get | view] (2008-08-12 20:15:46, 7.9 KB) [[attachment:irssi_audacious_v1.0.3.pl]]
  • [get | view] (2008-08-14 19:41:53, 9.9 KB) [[attachment:irssi_audacious_v1.0.4.pl]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.