Roadmap
Attachment 'irssi_audacious_v1.0.3.pl'
Download 1 use strict;
2 use vars qw($VERSION %IRSSI);
3 # Audacious Irssi Script v1.0.3
4 #
5 # Change Log:
6 # v1.0.3:
7 # - Added Playlist functionality
8 # - Added Song details (Bitrate/Frequency/Length/Volume)
9 # - Current song notice with song details (Optional)
10 # v1.0.2:
11 # - The script now handles warning support if you got audacious not running
12 # - Added track number, current time elapse and total track time
13 # - Added Stop functionality
14 # v1.0.1:
15 # - Added ability to autonotify the channel after skipping a song (optional)
16 # - Added Skip/Play/Pause/Resume calls
17 #
18 # How To Use?
19 # Copy your script into ~/.irssi/scripts/ directory
20 # Load your script with /script load audacious in your Irssi Client
21 # Type '/audacious help' in any channel for script commands
22 # For autoload insert your script into ~/.irssi/scripts/autorun/ directory
23 # Even better would be if you placed them in ~/.irssi/scripts/ and created symlinks in autorun directory
24 #
25 use Irssi;
26 $VERSION = '1.0.3';
27 %IRSSI = (
28 authors => "Dani Soufi",
29 contact => "IRC: FreeNode Network, #Ubuntu-LB",
30 name => "Audacious Irssi Script",
31 description => "Displays Current Song".
32 "Skips/Plays/Pauses/Stops/Resumes Songs".
33 "Displays Script/Player's Current Version".
34 "Current song details",
35 license => "Public Domain",
36 );
37
38 sub cmd_song {
39 my ($data, $server, $witem) = @_;
40 # Get current song information.
41 # If you want song details to be displayed
42 # directly with the current song:
43 # - Uncomment lines: 50/51/56/57/60
44 # -* Comment line 59 (Important)
45 if ($witem && ($witem->{type} eq "CHANNEL")) {
46 if (`ps -C audacious` =~ /audacious/) {
47 my $position = `audtool --playlist-position`;
48 my $song = `audtool --current-song`;
49 my $current = `audtool --current-song-output-length`;
50 my $total = `audtool --current-song-length`;
51 # my $bitrate = `audtool --current-song-bitrate-kbps`; #line 50
52 # my $frequency = `audtool --current-song-frequency-khz`; #line 51
53 chomp($song);
54 chomp($position);
55 chomp($current);
56 chomp($total);
57 # chomp($bitrate); #line 56
58 # chomp($frequency); #line 57
59
60 $witem->command("/me is listening to: #$position | $song ($current/$total)"); #line 59
61 # $witem->command("/me is listening to: #$position | $song ($current/$total) [$bitrate kbps/$frequency khz]"); #line 60
62 }
63 else {
64 $witem->print("Audacious is not currently running.");
65 }
66 return 1;
67 }
68 }
69
70 sub cmd_next {
71 my ($data, $server, $witem) = @_;
72 # Skip to the next track.
73 if ($witem && ($witem->{type} eq "CHANNEL")) {
74 if (`ps -C audacious` =~ /audacious/) {
75 my $playing = `audtool --playlist-advance`;
76 # Uncomment those lines if you want the script to
77 # automatically notify the channel to what song you have skipped
78 # my $position = `audtool --playlist-position`;
79 # my $song = `audtool --current-song`;
80 # chomp($position);
81 # chomp($song);
82
83 $witem->print("Skipped to next track.");
84 # $witem->command("/me has skipped to: #$position $song");
85 }
86 else {
87 $witem->print("Can't skip to next track. Check your Audacious.");
88 }
89 return 1;
90 }
91 }
92
93 sub cmd_previous {
94 my ($data, $server, $witem) = @_;
95 # Skip to the previous track.
96 if ($witem && ($witem->{type} eq "CHANNEL")) {
97 if (`ps -C audacious` =~ /audacious/) {
98 my $playing = `audtool --playlist-reverse`;
99 # Uncomment those lines if you want the script to
100 # automatically notify the channel to what song you have skipped
101 # my $position = `audtool --playlist-position`;
102 # my $song = `audtool --current-song`;
103 # chomp($position);
104 # chomp($song);
105
106 $witem->print("Skipped to previous track.");
107 # $witem->command("/me has skipped to: #$position $song");
108 }
109 else {
110 $witem->print("Can't skip to next track. Check your Audacious.");
111 }
112 return 1;
113 }
114 }
115
116 sub cmd_playing {
117 my ($data, $server, $witem) = @_;
118 # Start playback.
119 if ($witem && ($witem->{type} eq "CHANNEL")) {
120 if (`ps -C audacious` =~ /audacious/) {
121 my $playing = `audtool --playback-play`;
122
123 $witem->print("Started playback.");
124 }
125 else {
126 $witem->print("Playback can't be performed now.");
127 }
128 return 1;
129 }
130 }
131
132 sub cmd_pause {
133 my ($data, $server, $witem) = @_;
134 # Pause playback.
135 if ($witem && ($witem->{type} eq "CHANNEL")) {
136 if (`ps -C audacious` =~ /audacious/) {
137 my $pause = `audtool --playback-pause`;
138
139 $witem->print("Paused playback.");
140 }
141 else {
142 $witem->print("Pause can be only performed when Audacious is running.");
143 }
144 return 1;
145 }
146 }
147
148 sub cmd_stop {
149 my ($data, $server, $witem) = @_;
150 # Pause playback.
151 if ($witem && ($witem->{type} eq "CHANNEL")) {
152 if (`ps -C audacious` =~ /audacious/) {
153 my $pause = `audtool --playback-stop`;
154
155 $witem->print("Stopped playback.");
156 }
157 else {
158 $witem->print("This way you can't start Audacious.");
159 }
160 return 1;
161 }
162 }
163
164 sub cmd_playlist {
165 my ($data, $server, $witem) = @_;
166 # Displays entire playlist loaded.
167 if (`ps -C audacious` =~ /audacious/) {
168 my $display = `audtool --playlist-display`;
169 chomp($display);
170
171 Irssi::print("$display");
172 }
173 else {
174 $witem->print("Start your player first.");
175 }
176 return 1;
177 }
178
179 sub cmd_details {
180 my ($data, $server, $witem) = @_;
181 # Displays current song's details.
182 if ($witem && ($witem->{type} eq "CHANNEL")) {
183 if (`ps -C audacious` =~ /audacious/) {
184 my $bitrate = `audtool --current-song-bitrate-kbps`;
185 my $frequency = `audtool --current-song-frequency-khz`;
186 my $length = `audtool --current-song-length`;
187 my $volume = `audtool --get-volume`;
188 chomp($bitrate);
189 chomp($frequency);
190 chomp($length);
191 chomp($volume);
192
193 $witem->print("Current song details: rate: $bitrate kbps - freq: $frequency khz - l: $length min - vol: $volume");
194 }
195 else {
196 $witem->print("Your player doesn't seem to be running");
197 }
198 return 1;
199 }
200 }
201
202 sub cmd_version {
203 my ($data, $server, $witem) = @_;
204 # Displays version information to the channel.
205 if ($witem && ($witem->{type} eq "CHANNEL")) {
206 my $audacious_version = `audacious --version`;
207 chop $audacious_version;
208
209 $witem->command("/me is running: Audacious Irssi Script v$VERSION with ".$audacious_version);
210 }
211 }
212
213 sub cmd_help {
214 my ($data, $server) = @_;
215 # Displays usage screen.
216 Irssi::print("* /audacious song - Display the current song playing to a channel.");
217 Irssi::print("* /audacious next - Start playback.");
218 Irssi::print("* /audacious previous - Start playback.");
219 Irssi::print("* /audacious play - Start playback.");
220 Irssi::print("* /audacious pause - Pause playback.");
221 Irssi::print("* /audacious stop - Stop playback.");
222 Irssi::print("* /audacious playlist - Displays entire playlist.");
223 Irssi::print("* /audacious details - Displays current song's details");
224 Irssi::print("* /audacious about - Displays version of the script and audacious in the channel.");
225 }
226
227 sub cmd_audacious {
228 my ($data, $server, $witem) = @_;
229 if ($data =~ m/^[(song)|(next)|(previous)|(play)|(pause)|(stop)|(help)|(playlist)|(details)|(about)]/i) {
230 Irssi::command_runsub('audacious', $data, $server, $witem);
231 }
232 else {
233 Irssi::print("Use /audacious <option> or check /help audacious for the complete list");
234 }
235 }
236
237 Irssi::command_bind ('audacious song', 'cmd_song');
238 Irssi::command_bind ('audacious next', 'cmd_next');
239 Irssi::command_bind ('audacious previous', 'cmd_previous');
240 Irssi::command_bind ('audacious play', 'cmd_playing');
241 Irssi::command_bind ('audacious pause', 'cmd_pause');
242 Irssi::command_bind ('audacious stop', 'cmd_stop');
243 Irssi::command_bind ('audacious help', 'cmd_help');
244 Irssi::command_bind ('audacious playlist', 'cmd_playlist');
245 Irssi::command_bind ('audacious details', 'cmd_details');
246 Irssi::command_bind ('audacious about', 'cmd_version');
247 Irssi::command_bind ('audacious', 'cmd_audacious');
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.You are not allowed to attach a file to this page.