Temperature Zone script

I quickly wrote a little script to strip out the temperature reading from files in /proc/acpi/thermal_zone. Clearly this is just a quick little hack and there must be a better way (HAL?), but it works for me.

Maybe I’ll roll my own little gnome panel applet that displays cute little icons and things.

#!/usr/bin/env python

def tempFromFile(filename):
  l = file(filename).read()
  try:
      return l.replace(" ", "").strip().split(":")[1]
  except IndexError:
      return "Unknown"

zones = (
  ("CPU", "/proc/acpi/thermal_zone/TZ1/temperature"),
  ("Video", "/proc/acpi/thermal_zone/TZ2/temperature"),
  ("Harddrive", "/proc/acpi/thermal_zone/TZ3/temperature")
)

for zone in zones:
  print zone[0] + ": " + tempFromFile(zone[1])

Leave a Response

(will not be published)
(optional)
Remember Me