#!/usr/bin/perl use FindBin; chdir "${FindBin::Bin}"; use lib "${FindBin::Bin}/lib"; use Cochrane::Store; use Data::Dumper; use LWP::UserAgent; my $ua = LWP::UserAgent->new; use POSIX qw//; $ENV{TZ} = 'UTC'; POSIX::tzset(); use Time::HiRes qw//; use strict; use warnings; use constant { FILES => { 'position.jpg' => 'http://localhost:8081/position?height=480&width=320', #'map02.jpg' => 'http://localhost:8081/map?zoom=2&height=480&width=320', #'map02.jpg' => 'http://localhost:8081/map?zoom=3&height=480&width=320', #'map04.jpg' => 'http://localhost:8081/map?zoom=4&height=480&width=320', #'map05.jpg' => 'http://localhost:8081/map?zoom=5&height=480&width=320', #'map06.jpg' => 'http://localhost:8081/map?zoom=6&height=480&width=320', #'map07.jpg' => 'http://localhost:8081/map?zoom=7&height=480&width=320', #'map08.jpg' => 'http://localhost:8081/map?zoom=8&height=480&width=320', #'map09.jpg' => 'http://localhost:8081/map?zoom=9&height=480&width=320', #'map10.jpg' => 'http://localhost:8081/map?zoom=10&height=480&width=320', #'map11.jpg' => 'http://localhost:8081/map?zoom=11&height=480&width=320', #'map12.jpg' => 'http://localhost:8081/map?zoom=12&height=480&width=320', #'map13.jpg' => 'http://localhost:8081/map?zoom=13&height=480&width=320', #'map14.jpg' => 'http://localhost:8081/map?zoom=14&height=480&width=320', 'map15.jpg' => 'http://localhost:8081/map?zoom=15&height=480&width=320', #'map16.jpg' => 'http://localhost:8081/map?zoom=16&height=480&width=320', 'map17.jpg' => 'http://localhost:8081/map?zoom=17&height=480&width=320', #'map18.jpg' => 'http://localhost:8081/map?zoom=18&height=480&width=320', 'pressure.jpg' => 'http://localhost:8081/pressure?height=480&width=320', 'temperature.jpg' => 'http://localhost:8081/temperature?height=480&width=320', 'power.jpg' => 'http://localhost:8081/power?height=480&width=320', }, }; while (1) { for my $file (sort(keys(%{FILES()}))) { my $request = FILES()->{$file}; my $response = $ua->get($request); if ($response->is_success) { Cochrane::Store->write_file(Cochrane::Store::PATH_RUN.'/display/'.$file, $response->decoded_content); } if (-f Cochrane::Store::PATH_RUN.'/display/'.$file) { system 'xloadimage', '-display', ':0.0', '-onroot', Cochrane::Store::PATH_RUN.'/display/'.$file; } Time::HiRes::sleep(6); } }