1
0
Fork 0

sb-disk: cleanup, use meters

This commit is contained in:
Luca Bilke 2024-09-23 14:47:30 +02:00
parent 61ac0b46fd
commit 4469bbc7fe
1 changed files with 19 additions and 4 deletions

View File

@ -1,11 +1,12 @@
#!/bin/sh
. "colors"
types=${SB_DISK_FS:-ext2,ext3,ext4,xfs,btrfs,vfat}
IFS='
'
types=${SB_DISK_FS:-ext2,ext3,ext4,xfs,btrfs,vfat}
first=true
for mnt in $(findmnt -Py -t "$types"); do
eval "$mnt"
case "$TARGET" in
@ -15,8 +16,22 @@ for mnt in $(findmnt -Py -t "$types"); do
/boot*) icon="󰐥" ;;
*) icon="" ;;
esac
$first || printf " "
printf "%b" "${icon} $(df -h "$TARGET" | awk ' /[0-9]/ {print $3 "/" $2}')"
percent=$(df "$TARGET" | awk 'NR != 1 { gsub(/%/, "", $5); print $5 }')
case "$(printf %d $((percent / 10)))" in
0 | 1) color=$fgwhite bar=▁ ;;
2) color=$fgwhite bar=▂ ;;
3 | 4) color=$fgwhite bar=▃ ;;
5) color=$fgwhite bar=▄ ;;
6 | 7) color=$fgwhite bar=▅ ;;
8) color=$fgorange bar=▆ ;;
9 | 10) color=$fgred bar=▇ ;;
*) color=$fgblack bar= ;;
esac
printf "%b <span %b %b>%b</span>" "${icon}" "${color}" "${bggray}" "${bar}"
first=false
done
printf "\n"