Categories
Linux Programming Science and Technology

Conky, Dell i8k Modules, and My First Ubuntu Bash Script

Conky Screenshot

Well, I started playing around with Conky yesterday — if you haven’t heard of it before, just know that it’s a neat little Linux program that runs in your background and uses very little resources that displays a very neat desktop overlay.  (Like in the picture in the Lifehacker article.)

Now, some of the stock Conky scripts were more than adequate, but I had always wanted my laptop’s CPU temperature to be displayed as well, so I had to figure out a way to do that.

Now, if you’re somewhat familiar with tinkering in Linux, you’ve probably heard of the wonderful “lm_sensors” package — it’s a neat package for Linux that helps display lots of information about motherboard temps and whatnot.  Unfortunately, due to most laptops “prorietary-ness,” lm_sensors does very little for you if you’re trying to get it to work on a laptop.

Now, I had heard of the “i8kutils” package for Linux — this was a package designed for Dell laptops in particular, to display and control fan and temperature information.

So, with that, I was off to work!

(Note — these instructions are mostly for Ubuntu/Debian installations, because that’s what I use.)

First, install the package “i8kutils” using your Linux computer’s package manager (Synaptic, if you’re using Ubuntu).

Second, add the module “i8k” to your “/etc/modules” file.  (This will start the process at boottime.)  Restart your laptop.

Third, you’ll have to create some Conky script files.  I assume you’ve already had a bit of experience at least installing Conky and starting it up.  If not, play around with the instructions in that Lifehacker article and come back here afterwards.

Now, I noticed that one of my conky script files was a file called “hddmonit.sh” which contained the text:

#!/bin/bash
echo “$(nc localhost 7634 | cut -d’|’ -f4)”

Now, using a little bit of deduction, I figured that this file used a command called “nc localhost 7634” to display a little bit of information, and then used pipe commands (the little “|” symbol) to further splice the info, extracting just the temperature of my laptop’s hard drive.

So, while “nc localhost 7634” outputted this:

|/dev/sda|ST980815A|43|C|

Using the command “(nc localhost 7634 | cut -d’|’ -f4” would output just “43”, which was the temperature of my hard drive.

(The “cut” command splices out specific text from a string it’s given, in this case the fourth (-f4) chunk of text seperated by a “|” chracter.)

Now, I learned that the “i8k” module, once loaded, could be accessed with the file at  “/proc/i8k”, which just contains a string like:

1.0 A32 7GGGGGG 53 -22 1 -22 90300 -1 2

From this you can see various Dell-specific information, the important part being “53”, which was my current processor temp.  (The items in the string are separated by spaces.)

So, I quickly made myself a new script file called “i8ktemps.sh” copying the contents of “hddmonit.sh” and changing them to:

#!/bin/bash
echo “$(head /proc/i8k | cut -d’ ‘ -f4)”

This file, when executed, will just output the fourth “chunk” in the file “/proc/i8k”, which as you remember is my current processor temp.

Now, I needed to edit my Conky configuration file, which is located in your home folder and is called “.conkyrc”.

Then I simply located the line:

${font weather:size=28}x ${font}HDD ${execi 1 ~/scripts/hddmonit.sh}C

Which displayed my hard drive temperature, and changed it to:

${font weather:size=28}x ${font}CPU ${execi 1 ~/scripts/i8ktemps.sh}C HDD ${execi 1 ~/scripts/hddmonit.sh}C

Which, when Conky was restarted, would display my hard drive temperature and my current processor temperature.

See?  It’s not that hard to program this stuff!  I did this all, both programming in the Linux “Bash” shell and coding in Conky’s personal configuration code, without any experience in either.  I just looked at what was there, and changed it.

Relevant Links:

http://www.arachnoid.com/linux/shell_programming.html

http://ubuntuforums.org/showthread.php?t=411800

http://www.linuxcommand.org/wss0010.php

One reply on “Conky, Dell i8k Modules, and My First Ubuntu Bash Script”

Leave a Reply