#!/bin/bash sock=/var/run/pibox/framebuffer.sock imgdir=~/img blackimg='black-x240.png' imglist=() sleeptime=10 # seconds hidecurloutput=1 debug=0 # -S FILE - True if the FILE exists and is a socket. # https://linuxize.com/post/bash-check-if-file-exists/ if [ ! -S ${sock} ]; then echo Unable to find unix socket. Pls fix.; exit 1; fi [ "$hidecurloutput" == "1" ] && curlout='-o /dev/null' || curlout='' trap ctrl_c INT function ctrl_c() { sudo curl -sS --unix-socket ${sock} -X POST --data-binary @${imgdir}/${blackimg} http://localhost/image $curlout tput cub 5 echo exiting exit 0 } function debuglog() { [ $debug -eq 0 ] && return echo $1 } function loadimgs() { for file in `ls $imgdir`; do debuglog "Found image file $file" [ ${file} == ${blackimg} ] && continue imglist[${#imglist[@]}]=${file} debuglog "Loaded image file $file" done } function displayimg() { newimg="${1}" debuglog "Displaying image ${1}" sudo curl -sS --unix-socket ${sock} -X POST --data-binary @${imgdir}/${newimg} http://localhost/image $curlout } loadimgs debuglog "Image list: ${imglist[@]}" while true; do for thisimg in ${imglist[@]}; do displayimg "${thisimg}" sleep ${sleeptime} done done