/usr/share/ekg2/scripts/xmms.pl is in ekg2-scripting-perl 1:0.4~pre+20120506.1-14build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | # XMMS-InfoPipe front-end - allow /np [dest]
#
# Thanks to ak for suggestions and even changes.
#
# /set xmms_fifo <dest of xmms-infopipe fifo>
# /set xmms_format <format of printed text>
# /set xmms_format_streaming <format for streams>
# /set xmms_print_if_stopped <ON|OFF>
# /set xmms_format_time <time format> - default is %m:%s
#
# xmms_format* takes these arguments:
# Variable Name Example
# ----------------------------------------------------
# Song specific:
# %status Status Playing
# %title Title Blue Planet Corporation - Open Sea
# %file File /mp3s/blue planet corporation - open sea.mp3
# %length Length 9:13
# %pos Position 0:08
# %bitrate Bitrate 160kbps
# %freq Sampling freq. 44.1kHz
# %pctdone Percent done 1.4%
# %channels Channels 2
# Playlist specific:
# %pl_total Total entries
# %pl_current Position in playlist
# ¤pl_pctdone Playlist Percent done
use strict;
use Ekg2;
our $VERSION = "2.0";
our %EKG2 = (
authors => 'Simon Shine',
contact => 'simon@blueshell.dk',
name => 'xmms',
description => 'XMMS-InfoPipe front-end - allow /np [-help] [dest]',
license => 'Public Domain',
changed => '2004-01-15'
);
# rewriten to ekg2 perl script by darkjames @ 2005-08-28
Ekg2::variable_add('xmms_fifo', '/tmp/xmms-info');
Ekg2::variable_add('xmms_format', 'np: %title at %bitrate [%pos of %length]');
Ekg2::variable_add('xmms_format_streaming', 'streaming: %title at %bitrate [%file]');
Ekg2::variable_add('xmms_format_time', '%m:%s');
Ekg2::variable_add('xmms_print_if_stopped', '1');
Ekg2::command_bind('np', 'cmd_xmms');
# Ekg2::command_bind('xmms', 'cmd_xmms');
# Tab completition
Ekg2::command_bind('np help', 'cmd_xmms');
## Ekg2::command_bind('xmms help', \&cmd_xmms);
sub cmd_xmms {
my ($name, $args) = @_;
$args =~ s/^\s+//;
$args =~ s/\s+$//;
if ($args =~ /^help/) {
Ekg2::echo("
Valid format strings for xmms_format and xmms_format_streaming:
%%status, %%title, %%file, %%length, %%pos, %%bitrate,
%%freq, %%pctdone, %%channels, %%pl_total, %%pl_current
Example: /set xmms_format np: %%title at %%bitrate [%%pctdone]
Valid format string for xmms_format_time:
%%m, %%s
Example: /set xmms_format_time %%m minutes, %%s seconds\n");
return;
}
my ($xf) = Ekg2::variable_find('xmms_fifo')->{value};
if (!-r $xf) {
if (!-r '/tmp/xmms-info') {
Ekg2::echo("Couldn't find a valid XMMS-InfoPipe FIFO.");
return;
}
$xf = '/tmp/xmms-info';
}
my %xi;
open(XMMS, $xf);
while (<XMMS>) {
chomp;
my ($key, $value) = split /: /, $_, 2;
$xi{$key} = $value;
}
close(XMMS);
my %fs;
# %status
$fs{'status'} = $xi{'Status'};
# %title
if ($fs{'status'} ne "Playing") {
if (Ekg2::variable_find('xmms_print_if_stopped')->{value} > 0) {
$fs{'title'} = sprintf('(%s) %s', $fs{'status'}, $xi{'Title'});
} else {
Ekg2::echo("XMMS is currently not playing.");
return;
}
} else {
$fs{'title'} = $xi{'Title'};
}
# %file
$fs{'file'} = $xi{'File'};
# %length
$fs{'length'} = &format_time($xi{'Time'});
# %pos
$fs{'pos'} = &format_time($xi{'Position'});
# %bitrate
$fs{'bitrate'} = sprintf("%.0fkbps", $xi{'Current bitrate'} / 1000);
# %freq
$fs{'freq'} = sprintf("%.1fkHz", $xi{'Samping Frequency'} / 1000);
# %pctdone
if ($xi{'uSecTime'} > 0) {
$fs{'pctdone'} = sprintf("%.1f%%%%", ($xi{'uSecPosition'} / $xi{'uSecTime'}) * 100);
} else {
$fs{'pctdone'} = "0.0%%";
}
# %channels
$fs{'channels'} = $xi{'Channels'};
# %pl_total
$fs{'pl_total'} = $xi{'Tunes in playlist'};
# %pl_current
$fs{'pl_current'} = $xi{'Currently playing'};
# %pl_pctdone
$fs{'pl_pctdone'} = sprintf("%.1f%%%%", ($fs{'pl_current'} / ($fs{'pl_total'} ? $fs{'pl_total'} : 1)) * 100);
my ($format) = ($xi{'uSecTime'} == "-1") ?
Ekg2::variable_find('xmms_format_streaming')->{value} :
Ekg2::variable_find('xmms_format')->{value};
foreach (keys %fs) {
$format =~ s/\%$_/$fs{$_}/g;
}
# sending it.
my ($sess) = Ekg2::session_current;
my ($wind) = Ekg2::window_current;
if ($sess && $sess->{connected} && $wind->{id} > 1) {
if ($args eq "") {
Ekg2::command("/msg $wind->{target} $format");
} else {
Ekg2::command("/msg $args $format");
}
} else {
Ekg2::echo($format);
}
}
sub format_time {
my ($m, $s) = split /:/, @_[0], 2;
my ($format) = Ekg2::variable_find('xmms_format_time')->{value};
$format =~ s/\%m/$m/g;
$format =~ s/\%s/$s/g;
return $format;
}
1;
|