~mdw
/
profile
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
el/dot-emacs.el: Preserve environment properly when clearing `LD_PRELOAD'.
[profile]
/
bin
/
disorder-notify
diff --git
a/bin/disorder-notify
b/bin/disorder-notify
index
780aadc
..
e801d3d
100755
(executable)
--- a/
bin/disorder-notify
+++ b/
bin/disorder-notify
@@
-3,6
+3,9
@@
sub notify ($$) {
my ($head, $body) = @_;
sub notify ($$) {
my ($head, $body) = @_;
+ $body =~ s:\&:&:g;
+ $body =~ s:\<:<:g;
+ $body =~ s:\>:>:g;
my $kid = fork;
defined $kid or return;
if (!$kid) {
my $kid = fork;
defined $kid or return;
if (!$kid) {
@@
-48,6
+51,8
@@
sub now_playing (;$) {
for (;;) {
open my $log, "-|", "disorder", "log";
for (;;) {
open my $log, "-|", "disorder", "log";
+ my $startp = 1;
+ my $stateinfo = undef;
LINE: while (<$log>) {
chomp;
my @f = ();
LINE: while (<$log>) {
chomp;
my @f = ();
@@
-76,7
+81,11
@@
for (;;) {
push @f, $t if defined $t;
my $what = $f[1];
push @f, $t if defined $t;
my $what = $f[1];
- if ($what eq "state") {
+ if ($what eq "volume" && $startp) {
+ $startp = 0;
+ notify "DisOrder state", "Connected: $startinfo";
+ now_playing;
+ } elsif ($what eq "state") {
my $st = $f[2];
my $msg;
my $np = 0;
my $st = $f[2];
my $msg;
my $np = 0;
@@
-87,9
+96,15
@@
for (;;) {
elsif ($st eq "pause") { $msg = "paused"; }
elsif ($st eq "resume") { $msg = "playing"; $np = 1; }
else { next LINE; }
elsif ($st eq "pause") { $msg = "paused"; }
elsif ($st eq "resume") { $msg = "playing"; $np = 1; }
else { next LINE; }
- notify "DisOrder state", ucfirst $msg;
- now_playing if $np;
+ if (!$startp) {
+ notify "DisOrder state", ucfirst $msg;
+ now_playing if $np;
+ } else {
+ if (defined $startinfo) { $startinfo .= "; " . $msg; }
+ else { $startinfo = $msg; }
}
}
+ } elsif ($what eq "scratched") {
+ notify "DisOrder state", "Scratched playing track";
} elsif ($what eq "playing") {
now_playing $f[2];
}
} elsif ($what eq "playing") {
now_playing $f[2];
}