aboutsummaryrefslogtreecommitdiff
path: root/cpu.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 /cpu.lua
parent6441db0a9408a88780494d476f6611a52b41a24d (diff)
downloadvicious-legacy-96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe.tar.xz
Make use of io.lines() where appropriate
Diffstat (limited to 'cpu.lua')
-rw-r--r--cpu.lua8
1 files changed, 3 insertions, 5 deletions
diff --git a/cpu.lua b/cpu.lua
index 9f3839e..7c4907c 100644
--- a/cpu.lua
+++ b/cpu.lua
@@ -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