}
format_time(status["time"], time)
- output["play_time_minimal_units"] = time["minimal_units"]
- output["play_time_percentage"] = time["percentage"]
- output["state"] = status["state"]
- output["song"] = song
- for (key in output) {
- print key, output[key]
+ state_symbol = symbol_of_state(status["state"])
+ print("status", sprintf("%s %s %s", state_symbol, time["minimal_units"], time["percentage"]))
+}
+
+function symbol_of_state(state) {
+ if (state = "play") {
+ return "▶"
+ } else if (state = "pause") {
+ return "❚❚"
+ } else if (state = "stop") {
+ return "⬛"
+ } else {
+ print("Error: unexpected value for state: ", state) > "/dev/stderr"
+ exit 1
}
}
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/state)"
- printf \
- "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}\n"
+ mpd="$(read_sensor ${dir}/khatus_x4_sensor_mpd/out/status)"
+ echo "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}"
sleep 1
done