From: Siraaj Khandkar Date: Wed, 6 Mar 2019 11:04:22 +0000 (-0500) Subject: Reimplement net status as checking carrier rather than addr X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=01da02dd035f18586b3435743c6840ad77ba62b9;p=khatus.git Reimplement net status as checking carrier rather than addr --- diff --git a/x2/Makefile b/x2/Makefile index 0c2f810..3ccc2b9 100644 --- a/x2/Makefile +++ b/x2/Makefile @@ -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 \ diff --git a/x2/src/awk/exe/bar.awk b/x2/src/awk/exe/bar.awk index 930db5d..9b7328c 100644 --- a/x2/src/awk/exe/bar.awk +++ b/x2/src/awk/exe/bar.awk @@ -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 "--" } diff --git a/x2/src/bash/exe/khatus.sh b/x2/src/bash/exe/khatus.sh index ec8270f..6526ab5 100644 --- a/x2/src/bash/exe/khatus.sh +++ b/x2/src/bash/exe/khatus.sh @@ -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 index 0000000..610a53d --- /dev/null +++ b/x2/src/bash/exe/khatus_sensor_net_carrier.sh @@ -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