birdcam-pi/randomvideo.sh

35 lines
907 B
Bash
Raw Normal View History

2021-09-21 21:45:00 +02:00
#!/bin/sh
2021-09-21 23:05:25 +02:00
folder="/home/pi/Video" ### var: path to video files
player="cvlc" ### var: player command
playerparam="--no-osd --play-and-exit" ### var: player parameters
player_path="$(command -v $player)"
player_package="vlc" ### var: player apt package
if [ -z "$player_path" ]; then
echo "Missing $player, try to install it ..."
echo "Check internet connection ..."
pingserver="raspbian.raspberrypi.org" ### var: pingcheck destination
if ! ping -q -c1 $pingserver>/dev/null; then
echo "No internet connection ..."
exit 0
fi
sudo apt-get update; sudo apt-get -y install $player_package
player_path="$(command -v $player)"
if [ -z "$player_path" ]; then
echo "Cannot install $player, exiting ..."
exit 0
fi
fi
2021-09-21 21:45:00 +02:00
while true; do
2021-09-21 21:55:50 +02:00
file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)"
$player $playerparam $file
2021-09-21 23:05:25 +02:00
done