dotfiles/.local/bin/bar

45 lines
781 B
Bash
Executable File

#!/usr/bin/env sh
fg=#141414
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)
tp=$(expr $full / 2)
[ $used -ge $tp ] && c=$red || c=$fg
echo "%{F$c}$used/$full%{F$fg}"
}
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 "%{r}$USER@$(hostname) - $(date "+%Y-%m-%d - %H:%M") - $(chkinet) - $(used) - $(batt) "
sleep $sleep
done