#! /bin/sh set -e . ./bin/khatus_x4_lib_common_sensor.sh dir="${prefix}/${host}" kill_all() { for pid_file in $(find $dir -type f -name pid) do kill -9 $(cat $pid_file) || true rm $pid_file done pkill khatus_x4 } read_sensor() { if test -f "$1" then cat "$1" else printf '%s\n' '--' fi } kill_all ./bin/khatus_x4_sensor_datetime & ./bin/khatus_x4_sensor_mpd & ./bin/khatus_x4_sensor_energy & while : do battery_state="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_state)" battery_percentage="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_percentage)" datetime="$(read_sensor ${dir}/khatus_x4_sensor_datetime/out/datetime)" mpd="$(read_sensor ${dir}/khatus_x4_sensor_mpd/out/status)" echo "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}" sleep 1 done