[SOLVED] Conky and hddtemp

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
iainrs
Level 2
Level 2
Posts: 53
Joined: Mon Nov 07, 2011 5:14 pm

[SOLVED] Conky and hddtemp

Post by iainrs »

I have a feeling that this is an old chestnut that has come to haunt an 'old nut'.
In the last week I have returned my main system to Linux Mint 20 - Xfce after 3-4 years cohabiting with Xubuntu.
Most of the transfer has gone well and I'm enjoying getting back to LM.
Many of the problems I've experienced are involved in incoming to terms with recent developments and this may be one.

I transferred my .conkyrc file (basically unchanged and working for 4+ years) and found that apart from having to convert some add-ons to Python3 the main problem is that I cannot use 'hddtemp' eg

Code: Select all

${goto 32}/dev/sda: ${font Liberation Sans:style=Bold:size=8}${color1}${hddtemp /dev/sda}°C${color}${font}
produces the error message :
conky: could not connect to hddtemp host
If I run hddtemp in the terminal I have to use sudo to make it work.
I have run "systemctl start hddtemp" and it is running OK.

After the best part of a day trawling the internet I'm feeling lost.
Can anyone help - please.
Thanks
Iain
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
all41
Level 19
Level 19
Posts: 9523
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Conky and hddtemp

Post by all41 »

iainrs wrote: Mon Nov 09, 2020 1:24 pm

Code: Select all

${goto 32}/dev/sda: ${font Liberation Sans:style=Bold:size=8}${color1}${hddtemp /dev/sda}°C${color}${font}
Try
${goto 32}/dev/sda: ${font Liberation Sans:style=Bold:size=8}${color1}${execi 1 hddtemp /dev/sda}°C${color}${font}
Everything in life was difficult before it became easy.
ajgreeny
Level 7
Level 7
Posts: 1662
Joined: Mon Nov 19, 2007 3:27 pm

Re: Conky and hddtemp

Post by ajgreeny »

I use hddtemp in my conky output and to enable use by myself as user I have to run command

Code: Select all

sudo chmod u+s /usr/sbin/hddtemp
just the one time to allow it to run as user.
A also use vnstat output and for that have to run command

Code: Select all

sudo chmod u+s /usr/bin/vnstat
I have to admit that man chmod does not help my complete understanding of what exactly those commands mean but here's what it says; I will leave you to decipher this as best you can, or perhaps someone else will tell us both.

Code: Select all

SETUID AND SETGID BITS
       chmod clears the set-group-ID bit of a regular file if the file's group ID does not match the user's effective group ID
       or  one of the user's supplementary group IDs, unless the user has appropriate privileges.  Additional restrictions may
       cause the set-user-ID and set-group-ID bits of MODE or RFILE to be ignored.  This behavior depends on  the  policy  and
       functionality of the underlying chmod system call.  When in doubt, check the underlying system behavior.

       For directories chmod preserves set-user-ID and set-group-ID bits unless you explicitly specify otherwise.  You can set
       or clear the bits with symbolic modes like u+s and g-s.  To clear these bits for directories with a  numeric  mode  re‐
       quires an additional leading zero, or leading = like 00755 , or =755
What I can tell you is that both hddtemp and vnstat now work without needing to be run as root.
iainrs
Level 2
Level 2
Posts: 53
Joined: Mon Nov 07, 2011 5:14 pm

Re: Conky and hddtemp

Post by iainrs »

Thanks guys !
ajgreeny's "sudo chmod u+s /usr/sbin/hddtemp" got me user access to 'hddtemp'.
However just putting
hddtemp {dev)
in .conkyrc now gave me full device description and temperature.
(eg: /
/dev/sda: WDC WD6400AAKS-22A7B2: 45°C

But I can now write a simple python script to extract what I want.

nb. 'exec hddtemp ... ' still produced an error
BUT
'execi .. hddtemp -n /dev.sda' worked.

[3 hours later] -n displays only the temperature - so no need for a script

Thanks again
Iain
ajgreeny
Level 7
Level 7
Posts: 1662
Joined: Mon Nov 19, 2007 3:27 pm

Re: [SOLVED} Conky and hddtemp

Post by ajgreeny »

To get rid of all the unwanted information from hddtemp I pipe the output to cut and just show the characters needed for the temp alone.

Code: Select all

${execi 60 hddtemp /dev/sda | cut -c 33-34} C
For others who want to use this, the cut character numbers may have to be different to mine depending on your hard disk.
User avatar
all41
Level 19
Level 19
Posts: 9523
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: [SOLVED] Conky and hddtemp

Post by all41 »

This line from my inxi.rc:
${goto 10}Storage HDD temp /dev/sdc${alignr}${execi 1 hddtemp -n /dev/sdc}C
Positioning and text statements aside, I think the -n modifier is what @iainrs is stating, and is correct.
No pipe needed
Everything in life was difficult before it became easy.
ajgreeny
Level 7
Level 7
Posts: 1662
Joined: Mon Nov 19, 2007 3:27 pm

Re: [SOLVED] Conky and hddtemp

Post by ajgreeny »

Well I never!
You live and learn, and I have certainly learned something new from this thread.
I spite of using hddtemp for several years in my conky output, I had nebver been aware of the -n option to show numerical output only.
I found the line in my config file from an old conky site many years ago so I wonder if the -n option is relatively new?

No worries anyway; I have now changed the config file to show your version in place of mine.
User avatar
zcot
Level 9
Level 9
Posts: 2838
Joined: Wed Oct 19, 2016 6:08 pm

Re: [SOLVED] Conky and hddtemp

Post by zcot »

iainrs wrote: Mon Nov 09, 2020 1:24 pm I have run "systemctl start hddtemp" and it is running OK.
Is it running(exited)?

You can turn it on in: xed admin:///etc/default/hddtemp
Locked

Return to “Compiz, Conky, Docks & Widgets”