stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] /proc/acpi/thermal_zone/ has gone in Linux kernel 2.6.37


From: Vitaly Mayatskikh
Subject: [STUMP] /proc/acpi/thermal_zone/ has gone in Linux kernel 2.6.37
Date: Sun, 13 Feb 2011 14:11:50 -0500
User-agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/23.2 Mule/6.0 (HANACHIRUSATO)

Hi!

After upgrade of my Archlinux to kernel 2.6.37 I noticed that
/proc/acpi/thermal_zone/ is no longer exist. This patch hopefully
fixes it, but I don't have old kernel with /proc/acpi/thermal_zone/
enabled. StumpWM fellows, who still have this directory, please, test
the patch.

diff --git a/contrib/cpu.lisp b/contrib/cpu.lisp
index 65731e1..e5b672f 100644
--- a/contrib/cpu.lisp
+++ b/contrib/cpu.lisp
@@ -126,13 +126,24 @@ utilization."
        (format nil "~,2FGHz" (/ mhz 1000))
        (format nil "~DMHz" mhz))))
 
-(defvar *acpi-thermal-zone* (first (last
-                                   (pathname-directory
-                                    (first (list-directory 
"/proc/acpi/thermal_zone/"))))))
+(defvar *acpi-thermal-zone*
+  (let ((proc-dir (list-directory #P"/proc/acpi/thermal_zone/"))
+        (sys-dir (list-directory #P"/sys/class/thermal/")))
+    (cond
+      (proc-dir
+       (cons :procfs
+             (make-pathname :directory (pathname-directory (first proc-dir))
+                            :name "temperature")))
+      (sys-dir
+       (cons :sysfs
+             (make-pathname :directory (pathname-directory (car (last 
sys-dir)))
+                            :name "temp"))))))
 
 (defun fmt-cpu-temp (ml)
   "Returns a string representing the current CPU temperature."
   (declare (ignore ml))
-  (get-proc-file-field (concatenate 'string "/proc/acpi/thermal_zone/"
-                                    *acpi-thermal-zone* "/temperature")
-                       "temperature"))
+  (format nil "~a°C"
+          (case (car *acpi-thermal-zone*)
+            (:procfs (get-proc-file-field (cdr *acpi-thermal-zone*) 
"temperature"))
+            (:sysfs   (with-open-file (f (cdr *acpi-thermal-zone*))
+                        (/ (read f) 1000))))))

-- 
wbr, Vitaly



reply via email to

[Prev in Thread] Current Thread [Next in Thread]