Checking NVIDIA graphics card temperature in shell

Let’s face it: Linux has awesome graphics. It’s still the only OS that supports Compiz effects (some of which were illegally copied by Apple), such as the famous desktop cube. But not every computer can handle these. These require you to use drivers for graphics cards from NVIDIA or ATI (though there are probably more). I have an NVIDIA graphics card, but if the graphics get slow, or I hear my computer’s fan working really hard, it makes me curious how hot my GPU is, and it’s a pain in the neck to get administrative privileges and sort through settings with a busy graphics card. So instead, I wrote another shell script.

Some of you may be wondering why I bother with shell. Sometimes there isn’t a graphical utility to access something. I don’t know how to write a GUI (at least, not for a NORMAL computer), and shell is pretty easy to learn. At least according to me, a programmer with years of experience…

nvidia-settings -q gpucoretemp -t

returns the temperature in Celsius. I really do prefer Metric, but I’m going to be hypocritical and use Fahrenheit. This requires a conversion which involves simple math that I won’t bother to type, since My computer already has ConvertAll, a program to convert any unit combination to any compatible unit combination. First we need to save the Celsius value to a variable, though.

CoreTempC=$(nvidia-settings -q gpucoretemp -t)

The parentheses allow the command “nvidia-settings -q gpucoretemp -t” to be treated as a single value. The dollar sign makes sure it returns “x” in Celsius instead of giving the variable the textual value “nvidia-settings -q gpucoretemp -t”. “CoreTempC” is the variable name, and the equal sign sets “CoreTempC” to the correct temperature. Variables can be entered into programs as “$VariableName” wherever you want to place their value. Now to convert.

CoreTempC=$(nvidia-settings -q gpucoretemp -t)
CoreTempF=$(convertall $CoreTempC C F -q)
echo $CoreTempF

That’s it! Save it as a text file, and be sure to make it executable through the file properties. Drag the file into a terminal window and hit enter to see your computer’s temperature. The format is “36 C = 96.8 F”, as an example. Now if you want to put this in a GUI or a screensaver, all you have to do is type it where it belongs. For example, the fish applet:

Thermal Fish applet

Or xscreensaver:

Hopefully this will be as useful to you as it is for me.

About these ads

About nicknackgus

I have worked with all sorts of stuff. I built a computer from parts, installed some operating systems on it, and set up all sorts of software, and I don't have enough space here to mention any advanced settings in any area. I've also worked in science, multimedia, special effects, and robotics.
This entry was posted in Linux, Programs, Shell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s