From 5fc0e2dae2cf5669669b9fada097aeab9779d017 Mon Sep 17 00:00:00 2001 From: zhrtz Date: Sun, 20 Sep 2015 22:13:31 -0400 Subject: [PATCH] Added hwmon interface support, dropped the annoying floating .0 with math.floor --- widgets/thermal.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/widgets/thermal.lua b/widgets/thermal.lua index 7592b72..b77f652 100644 --- a/widgets/thermal.lua +++ b/widgets/thermal.lua @@ -9,6 +9,7 @@ local tonumber = tonumber local setmetatable = setmetatable local string = { match = string.match } local helpers = require("vicious.helpers") +local math = { floor = math.floor } -- }}} @@ -24,6 +25,7 @@ local function worker(format, warg) local zone = { -- Known temperature data sources ["sys"] = {"/sys/class/thermal/", file = "temp", div = 1000}, ["core"] = {"/sys/devices/platform/", file = "temp2_input",div = 1000}, + ["hwmon"] = {"/sys/class/hwmon/", file = "temp1_input",div = 1000}, ["proc"] = {"/proc/acpi/thermal_zone/",file = "temperature"} } -- Default to /sys/class/thermal warg = type(warg) == "table" and warg or { warg, "sys" } @@ -34,7 +36,7 @@ local function worker(format, warg) local data = warg[3] and _thermal[warg[3]] or _thermal[zone[warg[2]].file] if data then if zone[warg[2]].div then - return {data / zone[warg[2]].div} + return {math.floor(data / zone[warg[2]].div)} else -- /proc/acpi "temperature: N C" return {tonumber(string.match(data, "[%d]+"))} end