From 575774bb6b3be2bb3a611a322819a914f06cfcc1 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 7 Aug 2017 15:06:51 +0200 Subject: [PATCH] specify topic on command-line --- mqtt-trend.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mqtt-trend.pl b/mqtt-trend.pl index e256a45..7047672 100755 --- a/mqtt-trend.pl +++ b/mqtt-trend.pl @@ -19,12 +19,15 @@ system "i3-msg layout splitv"; my $border = 2; -open(my $in, '-|', 'mosquitto_sub -h rpi2 -t stat/# -t fade/# -v'); +my $topic = 'fade/#'; +$topic = $ARGV[0] if $ARGV[0]; + +open(my $in, '-|', "mosquitto_sub -h rpi2 -t '$topic' -v"); while(<$in>) { s/\s+$//sg; my ($t,$v) = split(/\s/,$_,2); - warn "$t\t$v\n"; + print STDERR "$t=$v "; if ( ! exists $trend->{$t} && $v =~ m/^\d+/ ) { my $hist = $trend->{hist_spec}->{$t} || $trend->{hist_spec}->{__default}; -- 2.20.1