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

allow separator colors to be updated
[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 open     = io.open
11 local tonumber = tonumber
12
13 -- coretemp
14 -- lain.widget.temp
15
16 local function factory(args)
17     local temp     = { widget = wibox.widget.textbox() }
18     local args     = args or {}
19     local timeout  = args.timeout or 2
20     local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
21     local settings = args.settings or function() end
22
23     function temp.update()
24         local f = open(tempfile)
25         if f then
26             coretemp_now = tonumber(f:read("*all")) / 1000
27             f:close()
28         else
29             coretemp_now = "N/A"
30         end
31
32         widget = temp.widget
33         settings()
34     end
35
36     helpers.newtimer("coretemp", timeout, temp.update)
37
38     return temp
39 end
40
41 return factory