Combine mpd status and use symbolic state indicators
[khatus.git] / x4 / bin / khatus_x4_parse_mpd_status_currentsong
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
     }
 }
 
This page took 0.021046 seconds and 4 git commands to generate.