sunaku / wmiirc

Ruby configuration for WMII window manager
ISC License
82 stars 26 forks source link

Honor multiple thermal devices #29

Closed nougad closed 12 years ago

nougad commented 12 years ago
$ 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

sunaku commented 12 years ago

Good idea. I have an alternative suggestion: what if you could instantiate the thermal applet many times, once for each thermal device in your system? The current architecture is designed for this kind of usage.

nougad commented 12 years ago

oh yes, of course your are right. Is there a possibility to get the index of the applet? Something like:

acpi -t | grep "Thermal $index:"

or is it better to add a config option to the thermal status?

sunaku commented 12 years ago

Good idea. Automatic @id added in 643632d3ad0ecb3de45e99f54a572cfb377f9224.

sunaku commented 12 years ago

Closed by e305ec49ba7014d488a92296164b1f4298fb5ab6.