Hi everyone,
Hi Adrian,
thanks a lot for your Vicious library.

Using the thermal widget I had some trouble as I don't have any support
for the available data sources. The only thing I got is the kernel module
'k10temp' for my AMD Phenom II X4 945 CPU, kernel 3.2.0-0.bpo.3-amd64.

Temperature related files in /sys, that I have:

:r!find /sys -name "temp*"
/sys/devices/platform/w83627ehf.656/temp1_input
/sys/devices/platform/w83627ehf.656/temp1_max
/sys/devices/platform/w83627ehf.656/temp1_max_hyst
/sys/devices/platform/w83627ehf.656/temp1_alarm
/sys/devices/platform/w83627ehf.656/temp1_type
/sys/devices/platform/w83627ehf.656/temp2_input
/sys/devices/platform/w83627ehf.656/temp2_max
/sys/devices/platform/w83627ehf.656/temp2_max_hyst
/sys/devices/platform/w83627ehf.656/temp2_alarm
/sys/devices/platform/w83627ehf.656/temp2_type
/sys/devices/platform/w83627ehf.656/temp3_input
/sys/devices/platform/w83627ehf.656/temp3_max
/sys/devices/platform/w83627ehf.656/temp3_max_hyst
/sys/devices/platform/w83627ehf.656/temp3_alarm
/sys/devices/platform/w83627ehf.656/temp3_type
/sys/devices/pci0000:00/0000:00:18.3/temp1_input
/sys/devices/pci0000:00/0000:00:18.3/temp1_max
/sys/devices/pci0000:00/0000:00:18.3/temp1_crit
/sys/devices/pci0000:00/0000:00:18.3/temp1_crit_hyst

The files in /sys/devices/platform/w83627ehf.656/*, used by lm-sensor
will not give the corresponding results which I can see in the bios. But
the kernel module k10temp does it for me.

To get the directory used for k10temp do:
$lspci -Dk|grep -B 1 k10temp
0000:00:18.3 Host bridge: Advanced Micro Devices [AMD] Family 10h Processor 
Miscellaneous Control
        Kernel driver in use: k10temp

In this case warg for the thermal widget is the table: {"0000:00:18.3", 
"k10temp"}

In the attached patch, I added support for this kernel module into
thermal.lua. For better understanding I put some notes into the README
too.

Now I can use the widget like:
  cputemp = widget({ type = "textbox" })
  vicious.register(cputemp, vicious.widgets.thermal, " $1C", 19, 
{"0000:00:18.3", "k10temp"})

or, better (rounded):
  vicious.register(cputemp, vicious.widgets.thermal,
                   function (widget, args)
                       return string.format(" %dC", math.floor(args[1] + 0.5))
                    end,
                    19,
                    {"0000:00:18.3", "k10temp"})

Maybe, someone can use it...

Regards
-Juergen

PS:
To apply this patch, save this message to a file and do
  git am -i --scissors <filename>
in the git dir of Vicious

>8------------------------------------------------------------------------

* README: added examples and updated widget description for the Thermal widget

Signed-off-by: Juergen Descher <[email protected]>
---
 README              |   29 ++++++++++++++++++++++++++++-
 widgets/thermal.lua |    7 ++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/README b/README
index 69ca8ad..4ebce01 100644
--- a/README
+++ b/README
@@ -133,9 +133,17 @@ vicious.widgets.thermal
   - provides temperature levels of ACPI and coretemp thermal zones
   - takes the thermal zone as an argument, i.e. "thermal_zone0", or a
     table with 1st field as thermal zone, 2nd as data source -
-    available data sources are "proc", "core" and "sys" (which is the
+    available data sources are "proc", "core", "k10temp" and "sys" (which is 
the
     default when only the zone is provided) and 3rd optional argument
     as a temperature input file to read
+    - using "k10temp" as thermal zone is a bit different:
+      to get the path for your temperature data do:
+         lspci -Dk|grep -B 1 k10temp
+      you'll get something like this:
+         0000:00:18.3 Host bridge: Advanced Micro Devices [AMD] Family 10h 
Processor Miscellaneous Control
+         Kernel driver in use: k10temp
+      this will result in an  argument like:
+         {"0000:00:18.3", "k10temp"}
   - returns 1st value as temperature of requested thermal zone
 
 vicious.widgets.uptime
@@ -402,6 +410,25 @@ HDD temperature widget
     {/dev/sda} key/disk and appends "°C" to the returned value, does
     not provide the port argument so default port is used
 
+Thermal widget
+  tzswidget = widget({ type = "textbox" })
+  vicious.register(tzswidget, vicious.widgets.thermal, " $1C", 19, 
"thermal_zone0")
+
+  - updated every 19 seconds, requests temperature of the default "sys" thermal
+    zone and appends 'C' to the returned decimal value
+
+  cputemp = widget({ type = "textbox" })
+  vicious.register(cputemp, vicious.widgets.thermal,
+       function (widget, args)
+           return string.format(" %dC", math.floor(args[1] + 0.5))
+       end,
+       19,
+       {"0000:00:18.3", "k10temp"})
+
+  - updated every 19 seconds, displays temperature as an integer (rounded) with
+    a space as prefix and 'C' as suffix, using the kernel module k10temp for 
core
+    temperature
+
 Mbox widget
   mboxwidget = widget({ type = "textbox" })
   vicious.register(mboxwidget, vicious.widgets.mbox, "$1", 5, 
"/home/user/mail/Inbox")
diff --git a/widgets/thermal.lua b/widgets/thermal.lua
index c81431f..0519d7b 100644
--- a/widgets/thermal.lua
+++ b/widgets/thermal.lua
@@ -21,9 +21,10 @@ local function worker(format, warg)
     if not warg then return end
 
     local zone = { -- Known temperature data sources
-        ["sys"]  = {"/sys/class/thermal/",     file = "temp",       div = 
1000},
-        ["core"] = {"/sys/devices/platform/",  file = "temp2_input",div = 
1000},
-        ["proc"] = {"/proc/acpi/thermal_zone/",file = "temperature"}
+        ["sys"]     = {"/sys/class/thermal/",                     file = 
"temp",       div = 1000},
+        ["core"]    = {"/sys/devices/platform/",                  file = 
"temp2_input",div = 1000},
+        ["proc"]    = {"/proc/acpi/thermal_zone/",                file = 
"temperature"},
+        ["k10temp"] = {"/sys/module/k10temp/drivers/pci:k10temp/",file = 
"temp1_input",div = 1000}
     } --  Default to /sys/class/thermal
     warg = type(warg) == "table" and warg or { warg, "sys" }
 
-- 
1.7.10.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to