From: Andrew Ruthven Date: Mon, 19 Nov 2007 17:57:17 +0000 (+1300) Subject: Allow suppressing blocks of output from being displayed. X-Git-Tag: 0.5~18 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72ab78c9bfbea09605416a620b951b3b2d64da00;p=mythtv-status.git Allow suppressing blocks of output from being displayed. --- diff --git a/ChangeLog b/ChangeLog index 7095094..89494c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2007-11-20 Andrew Ruthven + Allow suppressing blocks of output. + 2007-11-18 Andrew Ruthven Add support for showing the version of the script. Now we should any schedule conflicts, or if the MythTV Perl API isn't diff --git a/bin/mythtv-status b/bin/mythtv-status index 0c68d89..bf67288 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -21,6 +21,7 @@ my $port = "6544"; my $description = undef; my $episode = undef; my $colour = undef; +my %display; my $VERSION = '0.5'; @@ -31,6 +32,13 @@ GetOptions( 'h|host=s' => \$host, 'p|port=s' => \$port, 'v|version' => \&print_version, + 'status!' => \$display{'Status'}, + 'encoders!' => \$display{'Encoders'}, + 'recording_now!' => \$display{'Recording Now'}, + 'scheduled_recordings!' => \$display{'Scheduled Recordings'}, + 'schedule_conflicts!' => \$display{'Schedule Conflicts'}, + 'next_recording!' => \$display{'Time till next recording'}, + ); die "Sorry, port isn't a number.\n" @@ -101,6 +109,7 @@ my @blocks = ( 'name' => 'Recording Now', 'type' => 'xpath', 'xpath' => "//Status/Encoders/Encoder/Program", + 'hide' => 'after', 'attrs' => [ qw/title endTime/ ], 'template' => "__title__ (Ends: __endTime__)", 'rewrite' => { @@ -117,6 +126,7 @@ my @blocks = ( 'type' => 'xpath', 'xpath' => '//Status/Scheduled/Program', 'defaults' => 'schedule', + 'hide' => 'after', 'subs' => { 'find_next' => sub { my $vars = shift; @@ -201,6 +211,16 @@ print '=' x length($title) . "\n"; for my $block (@blocks) { $block->{'format'} ||= 'multi line'; + my $hide = undef; + if (defined $display{ $block->{'name'} } + && $display{ $block->{'name'} } == 0) { + if (defined $block->{'hide'} && lc($block->{'hide'}) eq 'after') { + $hide = 1; + } else { + next; + } + } + # We might need to set some defaults. if (defined $block->{'defaults'}) { for my $field (keys %{ $defaults{ $block->{'defaults'} } }) { @@ -219,7 +239,7 @@ for my $block (@blocks) { $output = substitute_vars($block, { 'next_time' => $next_time }); } - if (defined $output && $output ne '') { + if (defined $output && $output ne '' && ! defined $hide) { print "$block->{'name'}:" . ($block->{'format'} eq 'one line' ? ' ' : "\n"); print $output . "\n\n"; } @@ -372,6 +392,10 @@ Display the episode (subtitle) for the scheduled recordings. The host to check, defaults to localhost. +=item B<--nostatus>, B<--noencoders>, B<--norecording_now>, B<--noscheduled_recordings>, B<--noschedule_conflicts>, B<--nonext_recording> + +Suppress displaying blocks of the output if they would normally be displayed. + =item B<-p PORT, --port=PORT> The port to use when connecting to MythTV, defaults to 6544.