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 /cpuinf.lua | |
parent | 6441db0a9408a88780494d476f6611a52b41a24d (diff) | |
download | vicious-legacy-96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe.tar.xz |
Make use of io.lines() where appropriate
Diffstat (limited to 'cpuinf.lua')
-rw-r--r-- | cpuinf.lua | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -5,7 +5,7 @@ -- {{{ Grab environment local tonumber = tonumber -local io = { open = io.open } +local io = { lines = io.lines } local setmetatable = setmetatable local string = { match = string.match } -- }}} @@ -17,12 +17,11 @@ module("vicious.cpuinf") -- {{{ CPU Information widget type local function worker(format) - -- Get cpuinfo - local f = io.open("/proc/cpuinfo") local cpu_id = nil local cpu_info = {} - for line in f:lines() do + -- Get CPU info + for line in io.lines("/proc/cpuinfo") do if string.match(line, "^processor.*") then cpu_id = string.match(line, "([%d]+)") elseif string.match(line, "^cpu MHz.*") then @@ -35,7 +34,6 @@ local function worker(format) cpu_info["{cpu"..cpu_id.." mb}"] = cpu_cache / 1024 end end - f:close() return cpu_info end |