Reimplement net status as checking carrier rather than addr
authorSiraaj Khandkar <siraaj@khandkar.net>
Wed, 6 Mar 2019 11:04:22 +0000 (06:04 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Wed, 6 Mar 2019 11:04:22 +0000 (06:04 -0500)
x2/Makefile
x2/src/awk/exe/bar.awk
x2/src/bash/exe/khatus.sh
x2/src/bash/exe/khatus_sensor_net_carrier.sh [new file with mode: 0644]

index 0c2f810..3ccc2b9 100644 (file)
@@ -38,6 +38,7 @@ BASH_EXECUTABLE_NAMES := \
        khatus_sensor_memory \
        khatus_sensor_mpd \
        khatus_sensor_net_addr_io \
+       khatus_sensor_net_carrier \
        khatus_sensor_net_wifi_status \
        khatus_sensor_procs \
        khatus_sensor_screen_brightness \
index 930db5d..9b7328c 100644 (file)
@@ -152,10 +152,11 @@ function bar_make_status_disk_io_r(    src) {
 # Network
 # -----------------------------------------------------------------------------
 
-function bar_make_status_net_iface_status(interface,    addr) {
-    cache_get(addr, "khatus_sensor_net_addr_io", "addr" Kfs interface, 5)
-    if (!addr["is_expired"] && addr["value"])
-        return "up"
+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"])
+        return "<>"
     else
         return "--"
 }
index ec8270f..6526ab5 100644 (file)
@@ -108,6 +108,7 @@ main() {
         ["--interval_bluetooth"]=1
         ["--interval_net_wifi"]=1
         ["--interval_net_io"]=1
+        ["--interval_net_carrier"]=1
         ["--interval_disk_space"]=1
         ["--interval_disk_io"]=1
         ["--interval_loadavg"]=1
@@ -207,6 +208,7 @@ main() {
     fork_poller "${opts['--interval_temp']}"       "$perf" "$pipe" "$bin" "$cmd_sens_temperature"
     fork_poller "${opts['--interval_fan']}"        "$perf" "$pipe" "$bin" "$cmd_sens_fan"
     fork_poller "${opts['--interval_mem']}"        "$perf" "$pipe" "$bin" "$cmd_sens_memory"
+    fork_poller "${opts['--interval_net_carrier']}" "$perf" "$pipe" "$bin" khatus_sensor_net_carrier
 
     stdbuf -o L tail -f "$pipe"
 }
diff --git a/x2/src/bash/exe/khatus_sensor_net_carrier.sh b/x2/src/bash/exe/khatus_sensor_net_carrier.sh
new file mode 100644 (file)
index 0000000..610a53d
--- /dev/null
@@ -0,0 +1,6 @@
+#! /bin/sh
+
+for interface in $(ls /sys/class/net)
+do
+    printf "%s %d\n" $interface $(cat /sys/class/net/$interface/carrier)
+done
This page took 0.032133 seconds and 4 git commands to generate.