From 30068e6d43270e37b0f5c3620cb1ec43d54d1d61 Mon Sep 17 00:00:00 2001 Message-Id: <30068e6d43270e37b0f5c3620cb1ec43d54d1d61.1714344840.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 21 Jul 2018 15:16:15 +0100 Subject: [PATCH] bin/disorder-notify: Refactor the state reporting machinery. Organization: Straylight/Edgeware From: Mark Wooding Accumulate the message in one step, and then report it. --- bin/disorder-notify | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) 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]; -- [mdw]