diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-03-13 02:11:41 +0100 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-03-13 02:11:41 +0100 |
commit | 96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe (patch) | |
tree | a3f33876efaf5a3473f8aaa72a08368009fc4d2e /net.lua | |
parent | 6441db0a9408a88780494d476f6611a52b41a24d (diff) | |
download | vicious-legacy-96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe.tar.xz |
Make use of io.lines() where appropriate
Diffstat (limited to 'net.lua')
-rw-r--r-- | net.lua | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -7,7 +7,7 @@ -- {{{ Grab environment local tonumber = tonumber local os = { time = os.time } -local io = { open = io.open } +local io = { lines = io.lines } local setmetatable = setmetatable local string = { match = string.match } local helpers = require("vicious.helpers") @@ -27,11 +27,10 @@ local unit = { ["b"] = 1, ["kb"] = 1024, -- {{{ Net widget type local function worker(format) - -- Get /proc/net/dev - local f = io.open("/proc/net/dev") local args = {} - for line in f:lines() do + -- Get NET stats + for line in io.lines("/proc/net/dev") do -- Match wmaster0 as well as rt0 (multiple leading spaces) local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):") if name ~= nil then @@ -68,7 +67,6 @@ local function worker(format) nets[name][2] = send end end - f:close() return args end |