Use of LANG=C and improved matching in fs.lua.

- Prepend LANG=C to the df call, so it always gets the information in a way
  it understands. Other languages do have other namings for "Filesystem" and
  some use , instead of . for the number seperator.

- Adapt the line.match line so it actually matches values. (Have the - last
  in the first match and teach it that mount targets can also have dots and colons
  in it)
This commit is contained in:
Joerg Jaspert 2009-08-16 13:10:39 +02:00 committed by Adrian C. (anrxc)
parent f8eb93a656
commit 7ad474bcbc
1 changed files with 2 additions and 2 deletions

4
fs.lua
View File

@ -16,7 +16,7 @@ module("vicious.fs")
-- {{{ Filesystem widget type
local function worker(format)
-- Get data from df
local f = io.popen("df -hP")
local f = io.popen("LANG=C df -hP")
local fs_info = {}
-- Format data
@ -26,7 +26,7 @@ local function worker(format)
-- table for each mount point with gmatch
local size, used, avail, usep, mount =
-- Instead match all at once, including network file systems
line:match("^[%w/-:%.]+[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d]+)%%[%s]+([-/%w]+)$")
line:match('^[/%w:%.-]+[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d]+)%%[%s]+([/%w:%.-]+)$')
fs_info["{"..mount.." size}"] = size
fs_info["{"..mount.." used}"] = used