dotfiles/.local/bin/bar

46 lines
850 B
Plaintext
Raw Normal View History

2022-12-20 12:02:52 +01:00
inet_int=iwm0
2023-02-08 01:42:20 +01:00
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}"
}
2022-10-02 00:16:21 +02:00
while true; do
me=$(echo "$USER@$(hostname)")
version=$(uname -rv)
date=$(date "+%Y-%m-%d %H:%M")
2022-12-20 12:02:52 +01:00
chkinet=$(ifconfig $inet_int | grep status | cut -d " " -f2-)
2023-02-08 01:42:20 +01:00
used=$(used)
batt=$(batt)
2022-12-20 12:02:52 +01:00
wttr=$(cat "$HOME/share/misc/wttr")
2023-02-21 23:28:40 +01:00
win=$( (xdotool getactivewindow getwindowname 2>/dev/null) || echo "Idle")
2022-10-02 00:16:21 +02:00
2023-02-21 23:28:40 +01:00
echo " $date $wttr | $win%{r}$me $version $chkinet $used $batt "
sleep 0.25
2022-10-02 00:16:21 +02:00
done