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.
4 Licensed under GNU General Public License v2
5 * (c) 2013, Luke Bonham
6 * (c) 2010-2012, Peter Hofmann
10 local markup = require("lain.util.markup")
11 local helpers = require("lain.helpers")
13 local awful = require("awful")
14 local beautiful = require("beautiful")
15 local wibox = require("wibox")
18 local string = { format = string.format,
19 match = string.match }
21 local setmetatable = setmetatable
24 -- lain.widgets.sysload
28 local args = args or {}
29 local refresh_timeout = args.refresh_timeout or 5
30 local show_all = args.show_all or false
31 local header = args.header or " Load "
32 local header_color = args.header_color or beautiful.fg_normal or "#FFFFFF"
33 local color = args.color or beautiful.fg_focus or "#FFFFFF"
34 local app = args.app or "top"
36 local mysysload = wibox.widget.textbox()
38 local mysysloadupdate = function()
39 local f = io.open("/proc/loadavg")
40 local ret = f:read("*all")
45 local a, b, c = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
46 mysysload:set_text(string.format("%s %s %s", a, b, c))
48 local a = string.match(ret, "([^%s]+) ")
49 mysysload:set_text(string.format("%s", a))
51 mysysload:set_markup(markup(header_color, header) ..
52 markup(color, mysysload._layout.text .. " "))
55 local mysysloadtimer = timer({ timeout = refresh_timeout })
56 mysysloadtimer:connect_signal("timeout", mysysloadupdate)
57 mysysloadtimer:start()
58 mysysloadtimer:emit_signal("timeout")
60 mysysload:buttons(awful.util.table.join(
63 helpers.run_in_terminal(app)
70 return setmetatable(sysload, { __call = function(_, ...) return worker(...) end })