dotfiles/.config/polybar/scripts/filesystem.sh

27 lines
605 B
Bash
Raw Normal View History

2018-05-03 20:23:53 +02:00
#/bin/sh
source $(dirname $0)/../.env
source $(dirname $0)/filesystem.data
2018-05-03 20:23:53 +02:00
output=""
for i in "${!parts[@]}"; do
avail=$(df -h ${parts[$i]} | tail -1 | tr -s ' ' | cut -d' ' -f4)
used=$(df -h ${parts[$i]} | tail -1 | tr -s ' ' | cut -d' ' -f5)
num=$(echo ${used} | cut -d'%' -f1)
if [ "$num" -gt 80 ] ; then
color="$MOCHA_RED"
2018-05-03 20:23:53 +02:00
elif [ "$num" -gt 50 ] ; then
color="$MOCHA_PEACH"
2018-05-03 20:23:53 +02:00
else
color="$MOCHA_MAUVE"
2018-05-03 20:23:53 +02:00
fi
output=$output"%{F${color}}${icons[$i]} $used%{F$MOCHA_TEXT} · $avail"
2018-05-03 20:23:53 +02:00
if [ $(($i + 1)) -ne "${#parts[@]}" ] ; then
output=$output" "
fi
done
2020-09-22 19:06:32 +02:00
echo "$output"