aboutsummaryrefslogtreecommitdiff
path: root/net.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-13 02:11:41 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-13 02:11:41 +0100
commit96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe (patch)
treea3f33876efaf5a3473f8aaa72a08368009fc4d2e /net.lua
parent6441db0a9408a88780494d476f6611a52b41a24d (diff)
downloadvicious-legacy-96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe.tar.xz
Make use of io.lines() where appropriate
Diffstat (limited to 'net.lua')
-rw-r--r--net.lua8
1 files changed, 3 insertions, 5 deletions
diff --git a/net.lua b/net.lua
index 365d3c6..0550557 100644
--- a/net.lua
+++ b/net.lua
@@ -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