Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor multiple thermal devices #29

Closed
nougad opened this issue Jan 2, 2012 · 4 comments
Closed

Honor multiple thermal devices #29

nougad opened this issue Jan 2, 2012 · 4 comments

Comments

@nougad
Copy link
Contributor

nougad commented Jan 2, 2012

$ 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
Copy link
Owner

sunaku commented Jan 2, 2012

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
Copy link
Contributor Author

nougad commented Jan 3, 2012

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
Copy link
Owner

sunaku commented Jan 3, 2012

Good idea. Automatic @id added in 643632d.

@sunaku
Copy link
Owner

sunaku commented Jan 3, 2012

Closed by e305ec4.

@sunaku sunaku closed this as completed Jan 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants