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

pull #19 satisfaction
[etc/awesome.git] / widgets / temp.lua
1
2 --[[
3                                                   
4      Licensed under GNU General Public License v2 
5       * (c) 2013, Luke Bonham                     
6                                                   
7 --]]
8
9 local newtimer     = require("lain.helpers").newtimer
10
11 local wibox        = require("wibox")
12
13 local io           = io
14 local tonumber     = tonumber
15
16 local setmetatable = setmetatable
17
18 -- coretemp
19 -- lain.widgets.temp
20 local temp = {}
21
22 local function worker(args)
23     local args     = args or {}
24     local timeout  = args.timeout or 5
25     local settings = args.settings or function() end
26
27     temp.widget = wibox.widget.textbox('')
28
29     function update()
30         local f = io.open("/sys/class/thermal/thermal_zone0/temp")
31         if f ~= nil
32         then
33             coretemp_now = tonumber(f:read("*all")) / 1000
34             f:close()
35         else
36             coretemp_now = "N/A"
37         end
38
39         widget = temp.widget
40         settings()
41     end
42
43     newtimer("coretemp", timeout, update)
44     return temp.widget
45 end
46
47 return setmetatable(temp, { __call = function(_, ...) return worker(...) end })