Fix coercion-related ambiguities
[khatus.git] / x2 / src / awk / exe / bar.awk
index bd37305..08750d4 100644 (file)
@@ -152,9 +152,19 @@ function bar_make_status_disk_io_r(    src) {
 # Network
 # -----------------------------------------------------------------------------
 
+function bar_make_status_net_iface_status(interface,    is_plugged_in) {
+    # TODO: Integrate connection/address status into the symbol somehow.
+    cache_get(is_plugged_in, "khatus_sensor_net_carrier", interface, 5)
+    if (!is_plugged_in["is_expired"] && is_plugged_in["value"] == 1)
+        return "<>"
+    else
+        return "--"
+}
+
 function bar_make_status_net_addr(interface,    src) {
     src = "khatus_sensor_net_addr_io"
-    return cache_get_fmt_def(src, "addr" Kfs interface, 5, "%s", "")
+    addr = cache_get_fmt_def(src, "addr" Kfs interface, 5, "%s")
+    return addr ? addr : "--"
 }
 
 function bar_make_status_net_io_w(interface,    src) {
@@ -172,6 +182,14 @@ function bar_make_status_net_wifi(interface,    src) {
     return cache_get_fmt_def(src, "status" Kfs interface, 10, "%s")
 }
 
+function bar_make_status_net_wifi_link(interface,    link) {
+    cache_get_fmt_def(link, "khatus_sensor_net_wifi_status", "link" Kfs interface, 10)
+    if (!link["is_expired"] && link["value"] > 0)
+        return sprintf("%d%%", link["value"])
+    else
+        return "--"
+}
+
 # -----------------------------------------------------------------------------
 # Bluetooth
 # -----------------------------------------------------------------------------
@@ -194,20 +212,21 @@ function bar_make_status_backlight_percent(    src) {
 # Volume
 # -----------------------------------------------------------------------------
 
-function bar_make_status_volume_alsa_device(device,    mu, vl, vr, show) {
-    cache_get(mu, "khatus_sensor_volume", "mute"      Kfs device, 5)
-    cache_get(vl, "khatus_sensor_volume", "vol_left"  Kfs device, 5)
-    cache_get(vr, "khatus_sensor_volume", "vol_right" Kfs device, 5)
+function bar_make_status_volume_alsa_device(device,    m, l, r, show) {
+    cache_get(m, "khatus_sensor_volume", "mute"      Kfs device, 5)
+    cache_get(l, "khatus_sensor_volume", "vol_left"  Kfs device, 5)
+    cache_get(r, "khatus_sensor_volume", "vol_right" Kfs device, 5)
     show = "--"
-    if (!mu["is_expired"] && !vl["is_expired"] && !vr["is_expired"]) {
-             if (mu["value"] == "yes") {show = "X"}
-        else if (mu["value"] == "no")  {show = vl["value"] " " vr["value"]}
-        else {
+    if (!m["is_expired"] && !l["is_expired"] && !r["is_expired"]) {
+        if (m["value"] == "yes")
+            show = "X"
+        else if (m["value"] == "no")
+            show = l["value"] #" " r["value"]
+        else
             msg_out_log_error(\
                 "bar_make_status_volume_alsa_device: " device ". ", \
-                "Unexpected value for 'mute' field: " mu["value"] \
+                "Unexpected value for 'mute' field: " m["value"] \
             )
-        }
     }
     return show
 }
@@ -240,11 +259,11 @@ function bar_make_status_mpd(    state, status) {
 
 function bar_make_status_mpd_state_known(symbol,    s, song, time, percentage) {
     s = "khatus_sensor_mpd"
-    song    = cache_get_fmt_def(s, "song"                   , 5, "%s", "?")
+    #song    = cache_get_fmt_def(s, "song"                   , 5, "%s", "?")
     time    = cache_get_fmt_def(s, "play_time_minimal_units", 5, "%s", "?")
     percent = cache_get_fmt_def(s, "play_time_percentage"   , 5, "%s", "?")
-    song    = substr(song, 1, Opt_Mpd_Song_Max_Chars)
-    return sprintf("%s %s %s %s", symbol, time, percent, song)
+    #song    = substr(song, 1, Opt_Mpd_Song_Max_Chars)
+    return sprintf("%s %s %s", symbol, time, percent)
 }
 
 # -----------------------------------------------------------------------------
This page took 0.031507 seconds and 4 git commands to generate.