From: Dobrica Pavlinusic Date: Tue, 21 Mar 2017 07:33:00 +0000 (+0100) Subject: draw numeric values using tredd X-Git-Url: http://git.rot13.org/?p=mqtt-homehub;a=commitdiff_plain;h=75bf20352750207b90db5b9fe80dc74d283662a4;hp=78cc6b69f81d3cce745590f281ca4aecf0ead0c5 draw numeric values using tredd --- diff --git a/mqtt-trend.pl b/mqtt-trend.pl new file mode 100755 index 0000000..e256a45 --- /dev/null +++ b/mqtt-trend.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl +use warnings; +use strict; + +my $trend = { + hist_spec => { + 'fade/LDR' => '300x1', + '__default' => '100x1', + } +}; + +sub DESTROY { + warn "DESTROY"; + system "killall mosquitto_sub trend"; +} +system "killall mosquitto_sub trend"; +system "i3-msg layout splitv"; +#system "i3-msg border none"; + +my $border = 2; + +open(my $in, '-|', 'mosquitto_sub -h rpi2 -t stat/# -t fade/# -v'); +while(<$in>) { + s/\s+$//sg; + + my ($t,$v) = split(/\s/,$_,2); + warn "$t\t$v\n"; + + if ( ! exists $trend->{$t} && $v =~ m/^\d+/ ) { + my $hist = $trend->{hist_spec}->{$t} || $trend->{hist_spec}->{__default}; + my $label = $t; + $label =~ s/^.+\///; + open($trend->{$t}, '|-', "trend -L $label -v - $hist"); + $border = 2; + } + + if ( $trend->{$t} ) { + select $trend->{$t}; + $| = 1; + print "$v\n"; + } else { + warn "CLOSED $!\n"; + } + + system "i3-msg border 1pixel" if $border-- > 0; +} +