| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
local type = type |
| 22 |
local tonumber = tonumber |
| 23 |
local string = { match = string.match } |
| 24 |
local math = { floor = math.floor } |
| 25 |
local helpers = require("vicious.helpers") |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
return helpers.setcall(function (format, warg) |
| 30 |
if not warg then return end |
| 31 |
|
| 32 |
local zone = { |
| 33 |
["sys"] = {"/sys/class/thermal/", file = "temp", div = 1000}, |
| 34 |
["core"] = {"/sys/devices/platform/", file = "temp2_input",div = 1000}, |
| 35 |
["hwmon"] = {"/sys/class/hwmon/", file = "temp1_input",div = 1000}, |
| 36 |
["proc"] = {"/proc/acpi/thermal_zone/",file = "temperature"} |
| 37 |
} |
| 38 |
warg = type(warg) == "table" and warg or { warg, "sys" } |
| 39 |
|
| 40 |
|
| 41 |
local _thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1]) |
| 42 |
|
| 43 |
local data = warg[3] and _thermal[warg[3]] or _thermal[zone[warg[2]].file] |
| 44 |
if data then |
| 45 |
if zone[warg[2]].div then |
| 46 |
return {math.floor(data / zone[warg[2]].div)} |
| 47 |
else |
| 48 |
return {tonumber(string.match(data, "[%d]+"))} |
| 49 |
end |
| 50 |
end |
| 51 |
|
| 52 |
return {0} |
| 53 |
end) |
| 54 |
|