taler-mdb-ads.sh (2100B)
1 #!/bin/bash 2 # 3 # This file is part of TALER 4 # Copyright (C) 2023, 2024 Taler Systems SA 5 # 6 # TALER is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as 8 # published by the Free Software Foundation; either version 3, or 9 # (at your option) any later version. 10 # 11 # TALER is distributed in the hope that it will be useful, but 12 # WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public 17 # License along with TALER; see the file COPYING. If not, see 18 # <http://www.gnu.org/licenses/> 19 # 20 # Author: Christian Grothoff 21 # 22 set -eu 23 24 function cleanup() 25 { 26 killall fbi 27 taler-mdb-display -c "$CONF" -i 28 exit 0 29 } 30 31 trap cleanup EXIT 32 33 CONF="$HOME/.config/taler.conf" 34 35 # Parse command-line options 36 while getopts ':c:h' OPTION; do 37 case "$OPTION" in 38 c) 39 CONF="$OPTARG" 40 ;; 41 h) 42 echo 'Supported options:' 43 # shellcheck disable=SC2016 44 echo ' -c $CONF -- set configuration' 45 ;; 46 ?) 47 exit_fail "Unrecognized command line option" 48 ;; 49 esac 50 done 51 shift $((OPTIND - 1)) 52 53 taler-mdb-display -c "$CONF" 54 55 FBDEV=$(taler-config -c "$CONF" -s taler-mdb -o FRAMEBUFFER_DEVICE) 56 57 DATA_HOME=$(taler-config -c "$CONF" -s paths -o DATADIR -f) 58 59 while true 60 do 61 HOUR=$(date +%H | sed -e "s/^0//") 62 if [[ HOUR -ge 8 && HOUR -lt 22 ]] 63 then 64 taler-mdb-display -c "$CONF" 65 for AD in $(ls "${DATA_HOME}"/ads/* | shuf) 66 do 67 DELAY=$(echo "$AD" | awk -F'[-.]' '{print $(NF-1)}') 68 fbi -d "$FBDEV" -a -m "768x576-75" -vt 2 -nocomments -noverbose "$AD" &> /dev/null 69 sleep "$DELAY" 70 # TODO: consider keeping track of the PID and only killing the PID we need to kill. 71 killall fbi 72 done 73 taler-mdb-display -c "$CONF" -i 74 else 75 # Night time, save power! 76 sleep 600 77 fi 78 done