Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Conky and hard disk temps.

  1. #1
    Join Date
    Jul 2007
    Location
    UK
    Beans
    16,844
    Distro
    Ubuntu Development Release

    Conky and hard disk temps.

    I got two temps from laptop but not hard drive.

    Disks utility can see it no problem. But hddtemp needs sudo. If disks can see it what is it using. I can use that then.
    Maybe have to look at disks source code.

    Anyone sorted this without resorting to sudoers etc etc.

  2. #2
    Join Date
    Jul 2005
    Location
    England
    Beans
    Hidden!

    Re: Conky and hard disk temps.

    Here's the line I use in my .conkyrc file to get hddtemp showing the temperature of the disk
    Code:
    Disk Temperature:        ${execi 60 hddtemp /dev/sda | cut -c 30-32} C
    You may need to change the figures I use in the "pipe to cut" to suit your system hardware without extraneous text.

    To get the output of hddtemp to show without using sudo you can simply change the mode of the hddtemp executable with command
    Code:
    sudo chmod u+s /usr/sbin/hddtemp
    which allows it to run as user.

    I do the same for vnstat output in conky, with the exception being that the executable for that is in /usr/bin not /usr/sbin
    DISTRO: Xubuntu 12.04-64bit --- Code-tags --- Boot-Repair --- Grub2 wiki & Grub2 Basics --- RootSudo

  3. #3
    Join Date
    Jul 2007
    Location
    UK
    Beans
    16,844
    Distro
    Ubuntu Development Release

    Re: Conky and hard disk temps.

    Ah righto that seems safe enough. I still wonder how Disks gets it though.

  4. #4
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Conky and hard disk temps.

    Another way is to run hddtemp as a daemon and get the data from it using netcat:

    http://linux.die.net/man/8/hddtemp

    See 'Tcp/Ip Daemon Mode'

    Being curious, I had a quick poke around in the code for the gnome-disks program and it uses 'udisks_drive_ata_get_smart_temperature()' from the udisks library to get the temperatures, i.e. it is not using a command line utility, it goes straight to the udisks daemon.

    http://udisks.freedesktop.org/docs/latest/

    However ... there is a command line utility called udisks that should give you hours of fun with Conky because it shows all the SMART data -- temperatures, power cycle counts, power on time.

    Code:
    $ udisks --show-info /dev/sda
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

  5. #5
    Join Date
    Jul 2007
    Location
    UK
    Beans
    16,844
    Distro
    Ubuntu Development Release

    Re: Conky and hard disk temps.

    Nice one r-senior this works a treat.

    Code:
    udisks --show-info /dev/sda | grep temp | cut -c 52-53
    [edit] this is now working in conky. ${execi 60 udisks --show-info /dev/sda | grep temp | cut -c 52-54}
    Last edited by philinux; December 8th, 2013 at 03:08 PM.

  6. #6
    Join Date
    Mar 2012
    Location
    New Meadows, Idaho
    Beans
    200
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Conky and hard disk temps.

    After installing the hddtemp daemon you can use the hddtemp variable from Conky.

    http://conky.sourceforge.net/variables.html
    Michael Nelson -=- AKA: Mopar1973Man
    Running 4 computers all with Ubuntu Linux 12.04 LTS

  7. #7
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Conky and hard disk temps.

    Nice! For anyone whose daemon is not started:

    Code:
    sudo dpkg-reconfigure hddtemp
    This also gives the option of making hddtemp suid root.
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

  8. #8
    Join Date
    Jul 2007
    Location
    UK
    Beans
    16,844
    Distro
    Ubuntu Development Release

    Re: Conky and hard disk temps.

    Question is how come udisks doesn't need sudo but hddtemp does. I'd be interested if anyone knows.

  9. #9
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Conky and hard disk temps.

    Quote Originally Posted by philinux View Post
    Question is how come udisks doesn't need sudo but hddtemp does. I'd be interested if anyone knows.
    Don't know the answer to that one, but r-senior's answer, installing hddtemp with the SUID, allowing it to be run by regular users
    is the way to use hddtemp with conky.

    Then you can just use in conky...
    Code:
    ${execpi 10 hddtemp -n /dev/sda}
    To change color according to temperature you can also send it to a colorize script...
    ColorTempHDD.sh
    Code:
    #!/bin/bash
    # colorize.sh
    # by: Crinos512
    
    COOL=25
    WARM=50
    
    if [[ $1 < $COOL ]]
       then echo "\${color7}"$1    # COOL
    elif [[ $1 > $WARM ]]
       then echo "\${color9}"$1    # HOT
    else echo "\${color8}"$1       # WARM
    fi
    
    exit 0
    Set your temp ranges.
    Define color7, color8 and color9 in your conky config or change "color7" etc to a color in the script...eg "color FF0000" or "color red"

    eg this is my conky line...
    Code:
    ${execpi 10 hddtemp -n /dev/sda | xargs /home/glen/conky/ColorTemp/ColorTempHDD.sh}°C
    You can use copies of the same script to colorize cpu and gpu temps.
    Last edited by stinkeye; December 8th, 2013 at 07:57 PM.

  10. #10
    Join Date
    Jul 2007
    Location
    UK
    Beans
    16,844
    Distro
    Ubuntu Development Release

    Re: Conky and hard disk temps.

    I decided to do away with hddtemp and use this.

    ${execi 60 udisks --show-info /dev/sda | grep temp | cut -c 52-54}

    Seems to work well.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •