]> git.madduck.net Git - etc/awesome.git/blob - widget/temp.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:

513bd3849bb8226e6b382bb93433f72ec85bbea0
[etc/awesome.git] / widget / temp.lua
1 --[[
2
3      Licensed under GNU General Public License v2
4       * (c) 2013, Luca CPZ
5
6 --]]
7
8 local helpers  = require("lain.helpers")
9 local wibox    = require("wibox")
10 local tonumber = tonumber
11
12 -- coretemp
13 -- lain.widget.temp
14
15 local function factory(args)
16     local temp         = { widget = wibox.widget.textbox() }
17     local args         = args or {}
18     local timeout      = args.timeout or 30
19     local settings     = args.settings or function() end
20
21     function temp.update()
22         helpers.async({"find", "/sys/devices", "-name", "temp"}, function(f)
23             temp_now = {}
24             local temp_value
25             for t in f:gmatch("[^\n]+") do
26                 temp_value = helpers.first_line(t)
27                 if temp_value then
28                     temp_now[tonumber(t:match("%d+"))] = temp_value / 1e3
29                 end
30             end
31             coretemp_now = temp_now[0] or "N/A"
32             widget = temp.widget
33             settings()
34         end)
35     end
36
37     helpers.newtimer("thermal", timeout, temp.update)
38
39     return temp
40 end
41
42 return factory