Grab wifi status from iwconfig instead of nmcli
[khatus.git] / bin / khatus_controller
index 60a6b19..c67e640 100755 (executable)
@@ -97,7 +97,7 @@
 {
     shift()
     shift()
-    db["net_wifi_status"] = $0
+    set_net_wifi_status()
 }
 
 /^OK in:BLUETOOTH_POWER/\
@@ -162,7 +162,7 @@ function set_volume(    mute, left, right) {
     } else if (mute == "yes") {
         db["volume"] = "X"
     } else {
-        error("Unexpected value for 'mute' field: " mute)
+        error("set_volume", "Unexpected value for 'mute' field: " mute)
     }
 }
 
@@ -213,7 +213,7 @@ function alert_check_mpd(    curr, prev, name, body) {
                 " - " db_mpd_song["Album:"] \
                 " - " db_mpd_song["Title:"]
         }
-        alert_trigger_low("alert_check_mpd", "NowPlaying", body)
+        alert_trigger_low("alert_check_mpd", "MpdNowPlaying", body)
     }
 }
 
@@ -338,6 +338,12 @@ function set_disk_io(    curr_w, curr_r, prev_w, prev_r) {
     db["disk_io_diff_r"] = curr_r - prev_r
 }
 
+function set_net_wifi_status(    interface) {
+    interface = $1
+    shift()
+    db["net_wifi_status", interface] = $0
+}
+
 function set_net_addr_io(    \
     interface, address, io_curr_w, io_curr_r, io_prev_w, io_prev_r\
 ) {
@@ -475,7 +481,7 @@ function make_status_net(    \
                     io_stat = "--"
                 }
                 if (interface ~ "^w") {
-                    label = label ":" db["net_wifi_status"]
+                    label = label ":" db["net_wifi_status", interface]
                 }
                 if (++count_printed > 1) {
                     sep = "  "
@@ -537,8 +543,11 @@ function debug(location, msg, values,    sep, vals, key, payload) {
     }
 }
 
-function error(msg) {
-    output_msg("ERROR", msg, "/dev/stderr")
+function error(location, msg) {
+    # TODO: Reconsider classifying internal errors as alerts
+    #       Maybe better to keep the error class distinct and provide a
+    #       an optional transformation from error to alert
+    alert_trigger_hi(location, "KhatusControllerError", msg)
 }
 
 function ensure_numeric(n) {
This page took 0.029809 seconds and 4 git commands to generate.