From 4a01d1eed413c3dc1cf67ed66fa960ea22ba79a7 Mon Sep 17 00:00:00 2001 From: Martin Selbmann Date: Thu, 24 Sep 2020 10:40:46 +0200 Subject: [PATCH] update README.md parse config parameters with jq from config.json --- README.md | 2 +- RandomVideo.sh | 21 +++++++++++++++------ buzzer.sh | 37 +++++++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index e3b6b12..b712c25 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ * placeholder videofile for "On Air"-Message ### config.json -* the config file in future +* configfile with all config parameters ### volumetest.sh * testscript for ramping soundcard output volume diff --git a/RandomVideo.sh b/RandomVideo.sh index 38b9e43..ede8f1c 100755 --- a/RandomVideo.sh +++ b/RandomVideo.sh @@ -1,15 +1,24 @@ #!/bin/sh # SPDX-License-Identifier: Unlicense -folder="/mnt/video" -player="cvlc" -playerparam="--play-and-exit --quiet --no-osd -A alsa --alsa-audio-device=front:CARD=Device,DEV=0" -pgrepplayer="vlc" +cmdjq="$(command -v jq)" -swupgpio=23 +if [ -z "$cmdjq" ]; then +i echo "Missing \"jq\"!" + exit 1 +fi + +configfile="config.json" + +folder="$($cmdjq -r ".RandomVideo | .folder" $configfile)" +player="$($cmdjq -r ".player" $configfile)" +playerparam="$($cmdjq -r ".playerparam" $configfile)" +pgrepplayer="$($cmdjq -r ".pgrepplayer" $configfile)" + +swupgpio="$($cmdjq -r ".swupgpio" $configfile)" playerfull="$(command -v $player) $playerparam" -swupstat=$($(command -v gpio) read $swupgpio) +swupstat="$($(command -v gpio) read $swupgpio)" if [ $# -eq 0 ]; then echo "Parameter fehlt" diff --git a/buzzer.sh b/buzzer.sh index b95aa6b..2e0ab24 100755 --- a/buzzer.sh +++ b/buzzer.sh @@ -1,24 +1,33 @@ #!/bin/sh # SPDX-License-Identifier: Unlicense -buzzergpio=0 -strobegpio=2 -swupgpio=23 -swdowngpio=25 +cmdjq="$(command -v jq)" -player="cvlc" -playerparam="--play-and-exit --quiet --no-osd -A alsa --alsa-audio-device=front:CARD=Device,DEV=0" -playerloop="--loop" +if [ -z "$cmdjq" ]; then + echo "Missing \"jq\"!" + exit 1 +fi -pgrepplayer="vlc" +configfile="config.json" -pollingtime=0.05 -buzzertimeout=2 -strobeduration=1 +buzzergpio="$(§cmdjq -r ".buzzer | .buzzergpio" $configfile)" +strobegpio="$(§cmdjq -r ".buzzer | .strobegpio" $configfile)" +swupgpio="$(§cmdjq -r ".swupgpio" $configfile)" +swdowngpio="$(§cmdjq -r ".buzzer | .swdowngpio" $configfile)" -volumetimeout=0.1 -volumedelay=0.1 -volumemax=60 +player="$(§cmdjq -r ".player" $configfile)" +playerparam="$(§cmdjq -r ".playerparam" $configfile)" +playerloop="$(§cmdjq -r ".buzzer | .playerloop" $configfile)" + +pgrepplayer="$(§cmdjq -r ".pgrepplayer" $configfile)" + +pollingtime="$(§cmdjq -r ".buzzer | .pollingtime" $configfile)" +buzzertimeout="$(§cmdjq -r ".buzzer | .buzzertimeout" $configfile)" +strobeduration="$(§cmdjq -r ".buzzer | .strobeduration" $configfile)" + +volumetimeout="$(§cmdjq -r ".buzzer | .volumetimeout" $configfile)" +volumedelay="$(§cmdjq -r ".buzzer | .volumedelay" $configfile)" +volumemax="$(§cmdjq -r ".buzzer | .volumemax" $configfile)" playerfull="$(command -v $player) $playerparam" cmdgpio="$(command -v gpio)"