Skip to content

Commit cc1eea3

Browse files
committed
Adding baraction.sh
1 parent 06232f8 commit cc1eea3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

baraction.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# baraction.sh for spectrwm status bar
3+
4+
## DISK
5+
hdd() {
6+
hdd="$(df -h | awk 'NR==4{print $3, $5}')"
7+
echo -e "HDD: $hdd"
8+
}
9+
10+
## RAM
11+
mem() {
12+
mem=`free | awk '/Mem/ {printf "%dM/%dM\n", $3 / 1024.0, $2 / 1024.0 }'`
13+
echo -e "$mem"
14+
}
15+
16+
## CPU
17+
cpu() {
18+
read cpu a b c previdle rest < /proc/stat
19+
prevtotal=$((a+b+c+previdle))
20+
sleep 0.5
21+
read cpu a b c idle rest < /proc/stat
22+
total=$((a+b+c+idle))
23+
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
24+
echo -e "CPU: $cpu%"
25+
}
26+
27+
## VOLUME
28+
vol() {
29+
vol=`amixer get Master | awk -F'[][]' 'END{ print $4":"$2 }' | sed 's/on://g'`
30+
echo -e "VOL: $vol"
31+
}
32+
33+
SLEEP_SEC=3
34+
#loops forever outputting a line every SLEEP_SEC secs
35+
36+
# It seems that we are limited to how many characters can be displayed via
37+
# the baraction script output. And the the markup tags count in that limit.
38+
# So I would love to add more functions to this script but it makes the
39+
# echo output too long to display correctly.
40+
while :; do
41+
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; |"
42+
sleep $SLEEP_SEC
43+
done

0 commit comments

Comments
 (0)