From: Siraaj Khandkar Date: Mon, 11 Feb 2019 00:34:32 +0000 (-0500) Subject: Combine mpd status and use symbolic state indicators X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=81f816230f652b7c07930807a8ec146e208ad4ca;p=khatus.git Combine mpd status and use symbolic state indicators --- diff --git a/x4/bin/khatus_x4_parse_mpd_status_currentsong b/x4/bin/khatus_x4_parse_mpd_status_currentsong index 3716928..7e670f0 100755 --- a/x4/bin/khatus_x4_parse_mpd_status_currentsong +++ b/x4/bin/khatus_x4_parse_mpd_status_currentsong @@ -39,12 +39,20 @@ END { } 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 } } diff --git a/x4/sanity_check b/x4/sanity_check index fea986c..8100c2f 100755 --- a/x4/sanity_check +++ b/x4/sanity_check @@ -35,8 +35,7 @@ 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/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