]> 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:

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