From 549c8bc5ba8bba9501915c2ba1303955a44de0be Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 14 Sep 2009 20:55:53 +0200 Subject: Remote file systems in fs widget are optional By default only local file systems are included now. In case a mounted NFS share dissapears from the network the widget would be left hanging there and has the potential to block everything else (including awesome it self). File system widget now takes an optional argument which, if true, will include remote file systems. --- fs.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'fs.lua') diff --git a/fs.lua b/fs.lua index 01b74e5..46757ad 100644 --- a/fs.lua +++ b/fs.lua @@ -15,17 +15,18 @@ module("vicious.fs") -- {{{ Filesystem widget type -local function worker(format) +local function worker(format, nfs) + -- Fallback to listing only local file systems + if nfs then nfs = "" else nfs = "--local" end + -- Get data from df - local f = io.popen("LANG=C df -hP") + local f = io.popen("LANG=C df -hP " .. nfs) local fs_info = {} for line in f:lines() do if not line:match("^Filesystem.*") then - -- Format helper can't deal with matrices, so don't setup a - -- table for each mount point, with gmatch local size, used, avail, usep, mount = - -- Instead match all at once, including network file systems + -- Match all at once, including network file systems line:match("^[%w%p]+[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d%.]+)[%a]?[%s]+([%d]+)%%[%s]+([%w%p]+)$") fs_info["{"..mount.." size}"] = size -- cgit v1.2.3