Unverified Commit 73610b85 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Show directory size

parent 754cb118
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ escape () {

file="$1"
total="$2"
bytes="0"
body=$(escape "$3")
info="/run/shm/msg.html"

@@ -22,8 +23,11 @@ fi

while true
do
  if [ -s "$file" ]; then

  if [ -s "$file" ] || [ -d "$file" ]; then
    bytes=$(du -sb "$file" | cut -f1)
  fi
  
  if (( bytes > 1000 )); then
    if [ -z "$total" ] || [[ "$total" == "0" ]] || [ "$bytes" -gt "$total" ]; then
      size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/')
@@ -33,6 +37,7 @@ do
    fi
    echo "${body//(\[P\])/($size)}"> "$info"
  fi
  fi

  sleep 1 & wait $!

done