#!/usr/bin/perl -w use Device::SerialPort; # spawn off automatic updater system "~/updatekiosk&"; system "gnome-screensaver&"; system "gnome-power-manager&"; my $PORT = "/dev/ttyS0"; my $port = Device::SerialPort->new($PORT); #port configuration 9600/8/N/1 $port->databits(8); $port->baudrate(9600); $port->parity("none"); $port->stopbits(1); $port->are_match("\r"); chdir '~/kiosk'; # kick off presentation to start things off $pres = `cd ~/kiosk;ls *.odp *.ppt 2>/dev/null|head -n1`; chomp $pres; $pres = "~/kiosk/".$pres; my $pid = spawnChild("ooffice -norestore -show $pres"); while(1) { # grab input if available my $input = $port->lookfor(); $port->stty_echo(0); # check to see if there was actually any input if (not $input) { # no input, wait half a second before checking again `sleep 0.5`; next; } # handle input chomp $input; if ($input eq "a") { # got good signal from motion sensor # kill presentation `killall -9 soffice.bin`; kill 9,$pid; `gnome-screensaver-command --poke`; $pid = -1; # run video `cd ~/kiosk;mplayer -fs *.flv *.avi *.mp4 *.mkv`; # kick off presentation again $pid = spawnChild("ooffice -norestore -show $pres"); } } sub spawnChild { my $childstring = shift @_; my $pid = fork(); if( $pid == 0 ){ # child process `$childstring`; exit 0; } return $pid; }