dotfiles/bin/bar

46 lines
850 B
Plaintext
Executable File

inet_int=iwm0
fg=#fff
bg=#000
red=#f92672
green=#a6e22e
blue=#66d9ef
yellow=#f4bf75
batt() {
num=$(apm -l)
bstat=$(apm -b)
case "$bstat" in
0|4|255) c=$fg; ;;
1) c=$yellow; ;;
2) c=$red; ;;
3) c=$green; ;;
esac
echo "%{F$c}$num%%{F$fg}"
}
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}"
}
while true; do
me=$(echo "$USER@$(hostname)")
version=$(uname -rv)
date=$(date "+%Y-%m-%d %H:%M")
chkinet=$(ifconfig $inet_int | grep status | cut -d " " -f2-)
used=$(used)
batt=$(batt)
wttr=$(cat "$HOME/share/misc/wttr")
win=$( (xdotool getactivewindow getwindowname 2>/dev/null) || echo "Idle")
echo " $date $wttr | $win%{r}$me $version $chkinet $used $batt "
sleep 0.25
done