1

This script worked in the past, then was updated for 14.04.

#!/bin/bash

while true; do
   val=$(sensors | awk '/temp1/ {print $2}')
   max="+75.0"
   if [[ "$val" > "$max" ]]; then
       dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
   fi
   sleep 10
   clear
   sensors
done
exit 0

In 16.04 it gives an error:

Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'Suspend'

Can it be updated so it would work in 16.04?

  • Intel powerclamp would serve you better I think. However it kicks in at 85C not 75C. – WinEunuuchs2Unix Jan 24 '17 at 18:17
  • @WinEunuuchs2Unix - Please provide an answer on that under Stop cpu from overheating and then link here. –  Jan 24 '17 at 18:22
  • 1
    This is worth reading on how to suspend in ubuntu 16.04 – Nick Sillito Jan 24 '17 at 18:26
  • I'd be happy to do that tonight after work. – WinEunuuchs2Unix Jan 24 '17 at 18:29
  • It probably not the answer that you are looking for but you best solution is probably to either clean the existing cooler on your CPU (they get clogged with dust after time) or buy a better cooler. I ender up fitting an artic cooler and it solved the problems. – Nick Sillito Jan 24 '17 at 18:30
  • @NickSillito - what part of the script should be replaced with systemctl suspend? –  Jan 24 '17 at 18:50
  • I suspect that you need to replace the line starting "dbus-send..." (ive not tested this) – Nick Sillito Jan 24 '17 at 18:55
  • @NickSillito - I think now it works but I fear what I did is lucky savage ignorance. Would you comment my answer? –  Jan 24 '17 at 21:05
  • Are you using 16.04 with Unity desktop ? i can write alternative script in python to do the job – Sergiy Kolodyazhnyy Jan 25 '17 at 00:16
  • @Serg - Not Unity, but Plasma 5. I want to use this no matter the DE, even in other ubuntu-based systems. My answer below works in KDE and Pantheon (elementary) Loki (also 16.04) –  Jan 25 '17 at 00:18
  • OK. I'll look into cross-desktop approaches. – Sergiy Kolodyazhnyy Jan 25 '17 at 00:20
  • 1
    @cipricus I've written an answer to stop overheating using Powerclamp rather than suspending. I've posted it on the link you requested here: http://askubuntu.com/questions/391474/stop-cpu-from-overheating/875872#875872 – WinEunuuchs2Unix Jan 25 '17 at 00:51
  • @MostafaAhangarha - the other question has an outdated answer. It will have a good answer if I post my answer here under it but not before. How should I proceed? Should I post my answer here under the old one? - I don't think I can trust my skills enough to edit the outdated answer. My answer got some up-votes but I need more confirmation before posting it under the old question. Closing the question will limit the contributions to this answer. –  Jan 25 '17 at 08:17
  • I agree. But I cannot remove my flag now. – Mostafa Ahangarha Jan 25 '17 at 09:08
  • I have radically updated the linked question and posted a bounty under that. –  Jan 25 '17 at 23:01
  • @cipricus posted answer on the suggested duplicate. Basically, it's a script that determines suspend method depending on your OS version. Let me know how it works for you. – Sergiy Kolodyazhnyy Jan 25 '17 at 23:54

1 Answers1

3

I have decided to vote to close this and to radically update the other question, where I expect an answer.


As the error was Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'Suspend', after the comment made by Nick Sillito under this question linking to this answer, I have modified the script in what I expect to be a rather barbaric manner (I'm CL-illiterate myself); I've simply replaced this entire part:

    dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend

with

    systemctl suspend

As indicated in the comment made by wjandreea: sleep 10 or a similar value shouldn't be removed (as I initially did); without that line, the modified script will use more power because instead of running every 10 seconds, it will as fast as possible -- upwards of several dozen times per second.

At this point he system goes to sleep when going above the level set in the line

max="+75.0"

As I want a higher value, 82, the script I use is:

#!/bin/bash

while true; do
   val=$(sensors | awk '/temp1/ {print $2}')
   max="+82.0"
   if [[ "$val" > "$max" ]]; then
                        systemctl suspend

   fi
   sleep 10
   clear
   sensors
done
exit 0
  • 1
    Your modified script uses more power because you removed sleep 10. So instead of running every 10 seconds, it runs as fast as possible -- upwards of several dozen times per second. – wjandrea Jan 27 '17 at 04:20
  • @wjandrea - that's exactly the kind of correction I was asking for! I will try to fix it, after that please take a look and comment again, and if something looks fishy you may also edit my answer. - You should even post under the linked answer and get the bounty, because this looks like an answer. –  Jan 27 '17 at 11:43