1
0
Fork 0
mirror of https://gitlab.com/dwt1/dotfiles.git synced 2023-02-13 20:55:19 -05:00
dwt1--dotfiles/baraction.sh

45 lines
867 B
Bash
Raw Normal View History

#!/bin/bash
# baraction.sh for spectrwm status bar
## DATE
dte() {
dte="$(date +"%A, %B %d %l:%M%p")"
echo -e "$dte"
}
## DISK
hdd() {
hdd="$(df -h | awk 'NR==4{print $3, $5}')"
echo -e "HDD: $hdd"
}
## RAM
mem() {
mem=`free | awk '/Mem/ {printf "%d MiB/%d MiB\n", $3 / 1024.0, $2 / 1024.0 }'`
echo -e "MEM: $mem"
}
## 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() {
vol=`amixer get Master | awk -F'[][]' 'END{ print $4":"$2 }'`
echo -e "VOL: $vol"
}
SLEEP_SEC=5
#loops forever outputting a line every SLEEP_SEC secs
while :; do
echo "$(cpu) | $(mem) | $(hdd) | $(vol) | $(dte)"
sleep $SLEEP_SEC
done