Combine mpd status and use symbolic state indicators
authorSiraaj Khandkar <siraaj@khandkar.net>
Mon, 11 Feb 2019 00:34:32 +0000 (19:34 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Mon, 11 Feb 2019 00:34:32 +0000 (19:34 -0500)
x4/bin/khatus_x4_parse_mpd_status_currentsong
x4/sanity_check

index 3716928..7e670f0 100755 (executable)
@@ -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
     }
 }
 
index fea986c..8100c2f 100755 (executable)
@@ -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
This page took 0.061922 seconds and 4 git commands to generate.