]> git.madduck.net Git - etc/awesome.git/blob - .config/awesome/lain/widget/sysload.lua

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:

manipulate default sink with audio commands
[etc/awesome.git] / .config / awesome / lain / widget / sysload.lua
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 helpers     = require("lain.helpers")
11 local wibox       = require("wibox")
12 local open, match = io.open, string.match
13
14 -- System load
15 -- lain.widget.sysload
16
17 local function factory(args)
18     local sysload  = { widget = wibox.widget.textbox() }
19     local args     = args or {}
20     local timeout  = args.timeout or 2
21     local settings = args.settings or function() end
22
23     function sysload.update()
24         local f = open("/proc/loadavg")
25         local ret = f:read("*all")
26         f:close()
27
28         load_1, load_5, load_15 = match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
29
30         widget = sysload.widget
31         settings()
32     end
33
34     helpers.newtimer("sysload", timeout, sysload.update)
35
36     return sysload
37 end
38
39 return factory