aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-17 19:10:59 +0200
committerDanilo M. <danix@danix.xyz>2026-09-17 19:10:59 +0200
commit0048d3075adfd0336def9a25ce039765e43b4b3a (patch)
tree42a27e5a6313884540c228453a1547f972b3b6c7 /lib
parent63d8dc8c4ec7a641efb614265478edfa7b7f0906 (diff)
downloadconky-theme-udt-0048d3075adfd0336def9a25ce039765e43b4b3a.tar.gz
conky-theme-udt-0048d3075adfd0336def9a25ce039765e43b4b3a.zip
feat: read the available column from df
Free space is read rather than derived: size - used overstates it by the root-reserved blocks, tens of gigabytes on a large filesystem, none of it available to anyone but root. Also asserts fs[3], the row whose device name ends in a digit. It sits next to a numeric column and is the row most likely to break a parser counting fields, and nothing covered it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/data.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/data.lua b/lib/data.lua
index d5203a8..98c6898 100644
--- a/lib/data.lua
+++ b/lib/data.lua
@@ -219,7 +219,8 @@ function M.df_parse(text)
for line in text:gmatch('[^\n]+') do
-- A data row ends in 'NN% /some/path'. The header ends in 'Mounted on',
-- which fails the percent match, so it is skipped without a special case.
- local size, used, pct, mount = line:match('(%d+)%s+(%d+)%s+%d+%s+(%d+)%%%s+(%S+)%s*$')
+ local size, used, avail, pct, mount =
+ line:match('(%d+)%s+(%d+)%s+(%d+)%s+(%d+)%%%s+(%S+)%s*$')
if size then
-- The device is kept so a caller can tell an NFS mount from a local one
-- and recover its server, which is how the disks card labels the two
@@ -231,6 +232,10 @@ function M.df_parse(text)
host = dev and dev:match('^([^/:]+):') or nil,
size = tonumber(size),
used = tonumber(used),
+ -- Read, not derived: size - used overstates free space by the
+ -- root-reserved blocks, which is tens of gigabytes on a large
+ -- filesystem and is not available to anyone but root.
+ avail = tonumber(avail),
pct = tonumber(pct),
}
end