2020-04-14 17:37:48 -04:00
|
|
|
#!/bin/bash
|
|
|
|
# baraction.sh for spectrwm status bar
|
|
|
|
|
|
|
|
## DISK
|
|
|
|
hdd() {
|
|
|
|
hdd="$(df -h | awk 'NR==4{print $3, $5}')"
|
|
|
|
echo -e "HDD: $hdd"
|
|
|
|
}
|
|
|
|
|
|
|
|
## RAM
|
|
|
|
mem() {
|
2020-04-20 09:28:19 -04:00
|
|
|
mem=`free | awk '/Mem/ {printf "%dM/%dM\n", $3 / 1024.0, $2 / 1024.0 }'`
|
2020-04-15 23:55:51 -04:00
|
|
|
echo -e "$mem"
|
2020-04-14 17:37:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
## CPU
|
|
|
|
cpu() {
|
|
|
|
read cpu a b c previdle rest < /proc/stat
|
|
|
|
prevtotal=$((a+b+c+previdle))
|
|
|
|
sleep 0.5
|
|
|
|
read cpu a b c idle rest < /proc/stat
|
|
|
|
total=$((a+b+c+idle))
|
|
|
|
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
|
|
|
|
echo -e "CPU: $cpu%"
|
|
|
|
}
|
|
|
|
|
|
|
|
## VOLUME
|
|
|
|
vol() {
|
2020-04-20 09:28:19 -04:00
|
|
|
vol=`amixer get Master | awk -F'[][]' 'END{ print $4":"$2 }' | sed 's/on://g'`
|
2020-04-14 17:37:48 -04:00
|
|
|
echo -e "VOL: $vol"
|
|
|
|
}
|
|
|
|
|
2020-04-20 09:28:19 -04:00
|
|
|
SLEEP_SEC=3
|
2020-04-14 17:37:48 -04:00
|
|
|
#loops forever outputting a line every SLEEP_SEC secs
|
2020-04-20 09:28:19 -04:00
|
|
|
|
|
|
|
# It seems that we are limited to how many characters can be displayed via
|
|
|
|
# the baraction script output. And the the markup tags count in that limit.
|
|
|
|
# So I would love to add more functions to this script but it makes the
|
|
|
|
# echo output too long to display correctly.
|
2020-04-14 17:37:48 -04:00
|
|
|
while :; do
|
2020-04-20 09:28:19 -04:00
|
|
|
echo "+@fg=1; +@fn=1;💻+@fn=0; $(cpu) +@fg=0; | +@fg=2; +@fn=1;💾+@fn=0; $(mem) +@fg=0; | +@fg=3; +@fn=1;💿+@fn=0; $(hdd) +@fg=0; | +@fg=4; +@fn=1;🔈+@fn=0; $(vol) +@fg=0; |"
|
2020-04-14 17:37:48 -04:00
|
|
|
sleep $SLEEP_SEC
|
|
|
|
done
|