From 43afbb1e52e1d1eb6920b8cc1ca3f8572e4de3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Tue, 4 Jan 2022 20:44:36 +0100 Subject: [PATCH] feat: add percentage of free space --- btrfs-list | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/btrfs-list b/btrfs-list index 2bd048e..c89997a 100755 --- a/btrfs-list +++ b/btrfs-list @@ -1050,13 +1050,15 @@ foreach my $line (@orderedAll) { if (exists $line->{free}) { my $displayProfile = $line->{profile}; $displayProfile .= "/" . $line->{mprofile} if ($line->{profile} ne $line->{mprofile}); - $extra = - "($displayProfile" . ', ' - . pretty_print_str($line->{free}, 2) - . ' free of ' - . pretty_print_str($line->{fssize}, 2); + $extra = sprintf( + "(%s, %s/%s free, %.02f%%", + $displayProfile, + pretty_print_str($line->{free}, 2), + pretty_print_str($line->{fssize}, 2), + $line->{free} * 100 / $line->{fssize} + ); if ($line->{unallocatable} && $line->{unallocatable} > MiB) { - $extra .= ', ' . pretty_print_str($line->{unallocatable}, 2) . ' unallocatable'; + $extra .= sprintf(', %s unallocatable', pretty_print_str($line->{unallocatable}, 2)); } $extra .= ')'; } ## end if (exists $line->{free...})