From: Mark Wooding Date: Sat, 21 Jul 2018 14:16:15 +0000 (+0100) Subject: bin/disorder-notify: Refactor the state reporting machinery. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/30068e6d43270e37b0f5c3620cb1ec43d54d1d61?hp=f1b1fa59c64071df6bb74a3446ebf1fbbd54bea6 bin/disorder-notify: Refactor the state reporting machinery. Accumulate the message in one step, and then report it. --- diff --git a/bin/disorder-notify b/bin/disorder-notify index d36db9a..757e12f 100755 --- a/bin/disorder-notify +++ b/bin/disorder-notify @@ -73,18 +73,15 @@ for (;;) { my $what = $f[1]; if ($what eq "state") { my $st = $f[2]; - if ($st eq "disable_random") { - notify "DisOrder state", "Random play disabled"; - } elsif ($st eq "enable_random") { - notify "DisOrder state", "Random play enabled"; - } elsif ($st eq "disable_play") { - notify "DisOrder state", "Playing disabled"; - } elsif ($st eq "enable_play") { - notify "DisOrder state", "Playing enabled"; - } elsif ($st eq "pause") { - notify "DisOrder state", "Paused"; - } elsif ($st eq "resume") { - notify "DisOrder state", "Resuming"; + my $msg; + if ($st eq "disable_random") { $msg = "random play disabled"; } + elsif ($st eq "enable_random") { $msg = "random play enabled"; } + elsif ($st eq "disable_play") { $msg = "playing disabled"; } + elsif ($st eq "enable_play") { $msg = "playing enabled"; } + elsif ($st eq "pause") { $msg = "paused"; } + elsif ($st eq "resume") { $msg = "playing"; } + else { next LINE; } + notify "DisOrder state", ucfirst $msg; } } elsif ($what eq "playing") { now_playing $f[2];