summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2023-01-29 13:14:04 +0100
committertv <tv@krebsco.de>2023-01-29 13:14:04 +0100
commitf5acf82913c470a73f0dd37fa826289d58663c37 (patch)
treef0afe9cd2e48591fc5abf44d42af14ba08515fd8
parentbfa64c08ae82c609cde9791491bc0cc4d3dec929 (diff)
tv q: replace wireless/online by net
-rw-r--r--tv/5pkgs/simple/q/default.nix50
1 files changed, 26 insertions, 24 deletions
diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix
index a7a149ddc..809e37e59 100644
--- a/tv/5pkgs/simple/q/default.nix
+++ b/tv/5pkgs/simple/q/default.nix
@@ -79,31 +79,34 @@ let
echo "VT: $(${pkgs.systemd}/bin/systemd-detect-virt)"
'';
- q-wireless = /* sh */ ''
+ q-net = /* sh */ ''
for dev in $(
- ${pkgs.iw}/bin/iw dev \
- | ${pkgs.gnused}/bin/sed -n 's/^\s*Interface\s\+\([0-9a-z]\+\)$/\1/p'
+ ${pkgs.iproute}/bin/ip a |
+ ${pkgs.gnused}/bin/sed -rn 's/^[0-9]+: ([^:]+):.*/\1/p' |
+ ${pkgs.gnugrep}/bin/grep -Ev '^(lo|retiolum|wiregrill)$'
+ # TODO wiregrill ping ni.w, retiolum ping ni.r
); do
- inet=$(${pkgs.iproute}/bin/ip addr show $dev \
- | ${pkgs.gnused}/bin/sed -n '
- s/.*inet \([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p
- ') \
- || unset inet
- ssid=$(${pkgs.iw}/bin/iw dev $dev link \
- | ${pkgs.gnused}/bin/sed -n '
- s/.*\tSSID: \(.*\)/\1/p
- ') \
- || unset ssid
- echo "$dev''${inet+ $inet}''${ssid+ $ssid}"
+ {
+ inet=$(${pkgs.iproute}/bin/ip addr show $dev \
+ | ${pkgs.gnused}/bin/sed -n '
+ s/.*inet \([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p
+ ')
+ ssid=$(${pkgs.iw}/bin/iw dev $dev link \
+ | ${pkgs.gnused}/bin/sed -n '
+ s/.*\tSSID: \(.*\)/\1/p
+ ')
+ latency=$(
+ /run/wrappers/bin/ping -W .25 -c 1 -I "$dev" ni.i 2>&1 |
+ ${pkgs.gnused}/bin/sed -rn '
+ s/.*time=([0-9.]+).*/online ni=\1/p
+ s/.*Network is unreachable.*/offline/p
+ s/.*100% packet loss.*/offline/p
+ '
+ )
+ echo "$dev''${inet:+ $inet}''${ssid:+ $ssid} $latency"
+ } &
done
- '';
-
- q-online = /* sh */ ''
- if ${pkgs.curl}/bin/curl -s google.com >/dev/null; then
- echo 'online'
- else
- echo offline
- fi
+ wait
'';
q-thermal_zone = /* sh */ ''
@@ -152,8 +155,7 @@ pkgs.writeBashBin "q" ''
(${q-intel_backlight}) &
${pkgs.q-power_supply}/bin/q-power_supply &
(${q-virtualization}) &
- (${q-wireless}) &
- (${q-online}) &
+ (${q-net}) &
(${q-thermal_zone}) &
wait
if test "$PWD" != "$HOME" && test -e "$HOME/TODO"; then