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 /cpu.lua | |
parent | 6441db0a9408a88780494d476f6611a52b41a24d (diff) | |
download | vicious-legacy-96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe.tar.xz |
Make use of io.lines() where appropriate
Diffstat (limited to 'cpu.lua')
-rw-r--r-- | cpu.lua | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -6,7 +6,7 @@ -- {{{ Grab environment local ipairs = ipairs -local io = { open = io.open } +local io = { lines = io.lines } local setmetatable = setmetatable local math = { floor = math.floor } local table = { insert = table.insert } @@ -28,11 +28,10 @@ local cpu_active = {} -- {{{ CPU widget type local function worker(format) - -- Get /proc/stat - local f = io.open("/proc/stat") local cpu_lines = {} - for line in f:lines() do + -- Get CPU stats + for line in io.lines("/proc/stat") do if string.find(line, "^cpu") then cpu_lines[#cpu_lines+1] = {} @@ -41,7 +40,6 @@ local function worker(format) end end end - f:close() -- Ensure tables are initialized correctly while #cpu_total < #cpu_lines do |