Improve overview and experiment naming
[khatus.git] / x2 / src / awk / exe / parse_bluetoothctl_show.awk
diff --git a/x2/src/awk/exe/parse_bluetoothctl_show.awk b/x2/src/awk/exe/parse_bluetoothctl_show.awk
new file mode 100644 (file)
index 0000000..3a02897
--- /dev/null
@@ -0,0 +1,34 @@
+/^Controller / {
+    controller = $2
+    controllers[++ctrl_count] = controller
+}
+
+/^\t[A-Z][A-Za-z]+:/ {
+    key = $1
+    sub(":$", "", key)
+    sub("^\t" $1 " *", "")
+    val = $0
+    data[controller, key] = val
+}
+
+END {
+    # Using the 1st seen controller. Should we select specific instead?
+    power_status = data[controllers[1], "Powered"]
+    if (ctrl_count > 0) {
+        if (power_status == "no") {
+            show = "off"
+        } else if (power_status == "yes") {
+            show = "on"
+        } else {
+            print_error("Unexpected bluetooth power status: " power_status)
+            show = "ERROR"
+        }
+    } else {
+        show = "n/a"
+    }
+    print("power_status", show)
+}
+
+function print_error(msg) {
+    print(msg) > "/dev/stderr"
+}
This page took 0.02533 seconds and 4 git commands to generate.