sunaku/wmiirc — Issue #29: Honor multiple thermal devices
Author: nougad
Created: 2012-01-02 09:18:24+00:00
State: open

$ acpi -t
Thermal 0: ok, 84.0 degrees C
Thermal 1: ok, 87.0 degrees C

patch:

--- a/status/thermal.yaml
+++ b/status/thermal.yaml
@@ -8,18 +8,26 @@ status:
high: 70

label: |
- device, status = `acpi -t`.chomp.split(/: */, 2)
- status, level = status.split(/, */)
+ max_status, max_temperature, unit = nil, 0, nil
+
+ `acpi -t`.each_line do |l|
+ device, status = l.chomp.split(/: */, 2)
+ status, level = status.split(/, */)
+ temperature, unit = level.split(" degrees")
+ temperature = temperature.to_f
+
+ max_status, max_temperature = status, temperature if temperature > max_temperature
+ end

color =
- case [level.to_f, @high, @critical].min
+ case [max_temperature, @high, @critical].min
when @critical then :error
when @high then :notice
end

- temperature = level.sub(' degrees', '').tr('CF', "\u2103\u2109")
+ temperature = "#{max_temperature} #{unit.tr('CF', "\u2103\u2109")}"

- [color, "\u2622", temperature, status]
+ [color, "\u2622", temperature, max_status]

control:
action:

It shows the maximal temperature