]> git.madduck.net Git - etc/awesome.git/blob - widgets/sysload.lua.orig

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

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