dotfiles/.local/bin/bar

42 lines
697 B
Bash
Executable File

#!/usr/bin/env sh
red=#cf6a4c
green=#99ad6a
yellow=#d8ad4c
sleep=1
batt() {
num=$(apm -l)
bstat=$(apm -b)
case "$bstat" in
0|4|255) c=""; ;;
1) c="-"; ;;
2) c="--"; ;;
3) c="++"; ;;
esac
echo "$c$num%"
}
used() {
used=$(vmstat | awk 'END {printf $3}' | tr -d "M")
full=$(expr $(sysctl -n hw.usermem) / 1048576)
echo "$used/$full"
}
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
}
while true; do
echo "%{c}$USER@$(hostname) - $(date "+%Y-%m-%d - %H:%M") - $(chkinet) - $(used) - $(batt) "
sleep $sleep
done