blob: 2abac33a0c2ab62d8c1aed838df1a903758ac58a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
--[[
Licensed under GNU General Public License v2
* (c) 2013, Luke Bonham
* (c) 2010-2012, Peter Hofmann
--]]
local newtimer = require("lain.helpers").newtimer
local wibox = require("wibox")
local io = { open = io.open }
local string = { format = string.format,
match = string.match }
local setmetatable = setmetatable
-- System load
-- lain.widgets.sysload
local sysload = {}
local function worker(args)
local args = args or {}
local timeout = args.timeout or 5
local settings = args.settings or function() end
sysload.widget = wibox.widget.textbox('')
function update()
local f = io.open("/proc/loadavg")
local ret = f:read("*all")
f:close()
load_1, load_5, load_15 = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
widget = sysload.widget
settings()
end
newtimer("sysload", timeout, update)
return sysload.widget
end
return setmetatable(sysload, { __call = function(_, ...) return worker(...) end })
|