Combine mpd status and use symbolic state indicators
[khatus.git] / x4 / sanity_check
1 #! /bin/sh
2
3 set -e
4
5 . ./bin/khatus_x4_lib_common_sensor.sh
6
7 dir="${prefix}/${host}"
8
9 kill_sensor() {
10 if test -f "$1"
11 then
12 kill $(cat "$1")
13 fi
14 }
15
16 read_sensor() {
17 if test -f "$1"
18 then
19 cat "$1"
20 else
21 printf '%s\n' '--'
22 fi
23 }
24
25 kill_sensor ${dir}/khatus_x4_sensor_datetime/pid
26 kill_sensor ${dir}/khatus_x4_sensor_mpd/pid
27 kill_sensor ${dir}/khatus_x4_sensor_energy/pid
28
29 ./bin/khatus_x4_sensor_datetime -d
30 ./bin/khatus_x4_sensor_mpd -d
31 ./bin/khatus_x4_sensor_energy -d
32
33 while :
34 do
35 battery_state="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_state)"
36 battery_percentage="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_percentage)"
37 datetime="$(read_sensor ${dir}/khatus_x4_sensor_datetime/out/datetime)"
38 mpd="$(read_sensor ${dir}/khatus_x4_sensor_mpd/out/status)"
39 echo "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}"
40 sleep 1
41 done
This page took 0.056108 seconds and 4 git commands to generate.