chiark
/
gitweb
/
~mdw
/
profile
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d22be3a
)
bin/disorder-notify: Print the current play position in `now-playing' output.
author
Mark Wooding
<mdw@distorted.org.uk>
Tue, 2 Jun 2020 16:13:00 +0000
(17:13 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Tue, 2 Jun 2020 16:13:00 +0000
(17:13 +0100)
bin/disorder-notify
patch
|
blob
|
blame
|
history
diff --git
a/bin/disorder-notify
b/bin/disorder-notify
index d26a565c04624964373f2cc5e6e167f991c10c04..b2967e2a53f7d1e7af82403e96a0aae035d07761 100755
(executable)
--- a/
bin/disorder-notify
+++ b/
bin/disorder-notify
@@
-142,11
+142,19
@@
sub decode_track_name ($\%) {
}
}
}
}
+sub fmt_duration ($) {
+ my ($n) = @_;
+ return sprintf "%d:%02d", int $n/60, $n%60;
+}
+
sub format_now_playing (\%) {
my ($info) = @_;
exists $info->{track} or return "Nothing.";
my $r = "$info->{artist}: ‘$info->{title}’";
$r .= ", from ‘$info->{album}’" if $info->{album};
sub format_now_playing (\%) {
my ($info) = @_;
exists $info->{track} or return "Nothing.";
my $r = "$info->{artist}: ‘$info->{title}’";
$r .= ", from ‘$info->{album}’" if $info->{album};
+ exists $info->{sofar} && exists $info->{length} and
+ $r .= sprintf " (%s/%s)",
+ fmt_duration $info->{sofar}, fmt_duration $info->{length};
$r .= "\n(chosen by $info->{submitter})" if exists $info->{submitter};
return $r;
}
$r .= "\n(chosen by $info->{submitter})" if exists $info->{submitter};
return $r;
}
@@
-157,6
+165,8
@@
sub get_now_playing ($) {
defined $r or return {};
my %info = split_fields $r;
decode_track_name $sk, %info;
defined $r or return {};
my %info = split_fields $r;
decode_track_name $sk, %info;
+ exists $info{sofar} and
+ $info{length} = send_command $sk, "length", $info{track};
return \%info;
}
return \%info;
}