6

I have a problem with conky. I installed hddtemp and my ssd is shown like this:

/dev/sda: Crucial_CT120M500SSD1: 39°C

now in conky I wrote:

${alignr 10}${color}SSD M500 Crucial 120GB Temp ${color1}${hddtemp /dev/sda}ºC

But desktop shows N/A°C.

How can I fix it? Regards

3 Answers 3

8

If you don't want to have hddtemp running in daemon mode all the time, you could also run hddtemp as an external command instead. However, hddtemp needs to be run as root:

$ hddtemp /dev/sda
/dev/sda: open: Permission denied
$ sudo hddtemp /dev/sda
/dev/sda: ST3500418AS: 35°C

So, you will first need to give your user permission to run the command. Run visudo and add this line to the sudoers file (change linofex to your actual username):

linofex  ALL=NOPASSWD:/usr/sbin/hddtemp

That should let you run sudo hddtemp without needing to enter a password.

Now, replace the line from your conkyrc file with:

${alignr 10}${color}SSD M500 Crucial 120GB Temp ${color1}${exec sudo hddtemp /dev/sda | awk '{print $NF}'}
8
  • I update sudoers file with the command, and now I can run hddtemp without password. But with the command conky doesn't show me the temp.
    – linofex
    Oct 13, 2015 at 17:47
  • @linofex did you use ${exec sudo hddtemp /dev/sda | awk '{print $NF}'}? If so, what does it show now? Oct 13, 2015 at 17:51
  • SSD M500 Crucial 120GB Temp °C
    – linofex
    Oct 13, 2015 at 17:52
  • @linofex and what command did you run in the exec? Not mine since I don't have a °C there. Show me the exact command you ran and also try with ${exec sudo /usr/sbin/hddtemp /dev/sda | awk '{print $NF}'}. Oct 13, 2015 at 18:47
  • ${alignr 10}${color}SSD M500 Crucial 120GB Temp ${color1}${exec sudo hddtemp /dev/sda | awk '{print $NF}' } show SSD M500 Crucial 120GB Temp ${exec sudo /usr/sbin/hddtemp /dev/sda | awk '{print $NF}'} doesn't show nothing
    – linofex
    Oct 13, 2015 at 18:56
4

You need to first start hddtemp as a background daemon with the commmand:

 hddtemp -d /dev/sda

${hddtemp ...} is a conky built-in object. It connects to 127.0.0.1:7634 by default to get the disk temperatures. You therefore need to start, independently, the hddtemp daemon which listens on this port and replies with the information.

An alternative is to use ${exec hddtemp /dev/sda} which runs hddtemp on each window update, and does not need a daemon.


If you just want the temperature, pipe the output into awk to get the next-to-last field (in my case) ie $(NF-1), or the last field $NF in your case:

${exec hddtemp /dev/sda|awk '{print $NF}'}
4
  • what dose -d mean? (-daemon?)
    – linofex
    Oct 13, 2015 at 16:45
  • yes. see man hddtemp.
    – meuh
    Oct 13, 2015 at 16:47
  • If I run this command ' ${exec hddtemp /dev/sda} ' conky shows me all the information and not just the temp. How can I edit the command?
    – linofex
    Oct 13, 2015 at 17:50
  • @linofex like terdon says, pipe the output through awk to select just the last field .
    – meuh
    Oct 13, 2015 at 17:58
2

Another solution is to permit hddtemp with:

sudo chmod +s /usr/sbin/hddtemp

Then (based on your example), in your conkyrc file the item will become:

${execi 1 hddtemp /dev/sda|sed 's%/dev/sda: %%' }

This will give you just Crucial_CT120M500SSD1: 39°C.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.