wtf: further improvements

This commit is contained in:
Ingolf Wagner 2020-01-07 16:32:19 +13:00
parent c7ee7d395a
commit fe231d26b3
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

@ -3,6 +3,38 @@ let
unstable = import <nixpkgs-unstable> { };
networkStatus = let
q-online = ''
if ${pkgs.curl}/bin/curl -s google.com >/dev/null; then
echo 'status: online'
else
echo 'status: offline '
fi
'';
q-wireless = ''
for dev in $(
${pkgs.iw}/bin/iw dev \
| ${pkgs.gnused}/bin/sed -n 's/^\s*Interface\s\+\([0-9a-z]\+\)$/\1/p'
); 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' \
| ${pkgs.coreutils}/bin/tr -d '\r') \
|| unset ssid
printf '%s: %s %s\n' $dev ''${inet+ $inet} ''${ssid+ $ssid}
done
'';
in pkgs.writers.writeBash "network-status" ''
${q-wireless}
${q-online}
${pkgs.coreutils}/bin/uptime
'';
taskNextWeek = pkgs.writers.writeDash "taskweek" ''
${pkgs.taskwarrior}/bin/task \
export \
@ -183,15 +215,6 @@ let
refreshInterval = 3600;
};
uptime = cmdRunner {
title = "uptime";
cmd = "uptime";
top = 3;
left = 1;
height = 1;
width = 3;
};
active-users = cmdRunner {
title = "users";
cmd = activeUsers;
@ -221,6 +244,26 @@ let
width = 2;
refreshInterval = 60;
};
network-status = cmdRunner {
title = "network status";
cmd = networkStatus;
top = 3;
left = 1;
height = 1;
width = 3;
refreshInterval = 60;
};
uptime = cmdRunner {
enabled = false;
title = "uptime";
cmd = "uptime";
top = 3;
left = 1;
height = 1;
width = 3;
};
};
};
};