From: Mark Wooding Date: Sat, 21 Jul 2018 14:20:56 +0000 (+0100) Subject: bin/disorder-notify: Improve startup notifications. X-Git-Url: https://git.distorted.org.uk/~mdw/profile/commitdiff_plain/b106596ea51f33b91b4c1ab2a6748a5f099338ce bin/disorder-notify: Improve startup notifications. Accumulate the startup state dump, and also report the current track if there is one. --- diff --git a/bin/disorder-notify b/bin/disorder-notify index 780aadc..ac329ba 100755 --- a/bin/disorder-notify +++ b/bin/disorder-notify @@ -48,6 +48,8 @@ sub now_playing (;$) { for (;;) { open my $log, "-|", "disorder", "log"; + my $startp = 1; + my $stateinfo = undef; LINE: while (<$log>) { chomp; my @f = (); @@ -76,7 +78,11 @@ for (;;) { 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; @@ -87,8 +93,12 @@ for (;;) { 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 "playing") { now_playing $f[2];