dotfiles/.local/bin/bar

42 lines
697 B
Plaintext
Raw Normal View History

2023-07-06 01:58:18 +02:00
#!/usr/bin/env sh
2022-12-20 12:02:52 +01:00
2023-07-06 01:58:18 +02:00
red=#cf6a4c
green=#99ad6a
yellow=#d8ad4c
sleep=1
2023-02-08 01:42:20 +01:00
batt() {
num=$(apm -l)
bstat=$(apm -b)
case "$bstat" in
2023-07-06 01:58:18 +02:00
0|4|255) c=""; ;;
1) c="-"; ;;
2) c="--"; ;;
3) c="++"; ;;
2023-02-08 01:42:20 +01:00
esac
2023-07-06 01:58:18 +02:00
echo "$c$num%"
2023-02-08 01:42:20 +01:00
}
used() {
used=$(vmstat | awk 'END {printf $3}' | tr -d "M")
full=$(expr $(sysctl -n hw.usermem) / 1048576)
2023-07-07 16:45:46 +02:00
echo "$used/$full"
2023-02-08 01:42:20 +01:00
}
2023-07-06 01:58:18 +02:00
chkinet() {
out=$(ifconfig $(ifconfig | grep -E "UP,BROADCAST,RUNNING" | cut -f1 -d ":") | grep "status" | cut -f2 -d ":" | tr -d " ")
case "$out" in
"active") echo "Up"; ;;
"nonetwork") echo "Down"; ;;
esac
}
2022-10-02 00:16:21 +02:00
while true; do
2023-07-06 01:58:18 +02:00
echo "%{r}$USER@$(hostname) - $(date "+%Y-%m-%d - %H:%M") - $(chkinet) - $(used) - $(batt) "
sleep $sleep
2022-10-02 00:16:21 +02:00
done