Expert’s guide to configuring Conky

39243

Author: Dmitri Popov

When it comes to monitoring your Linux system, few tools can rival Conky. This lightweight system monitoring utility can help you to keep an eye on virtually any aspect of your system, and it offers a huge list of options to choose from. But this flexibility comes at a price: all Conky’s settings are stored in the .conkyrc file, which you have to create and tweak manually. The good news is that once you understand the inner workings of the .conkyrc file, you can easily create powerful Conky configuration profiles.

The .conkyrc file consists of two sections: the first controls Conky’s appearance, while the second determines what data to monitor. To separate these sections, Conky uses the TEXT marker. Since the .conkyrc file is just a plain text file, you can use your favorite text editor to work with it.

The first thing you have to do is specify the update interval, or how often Conky “collects” the monitored data. Specify the update_interval option in seconds; for example, update_interval 1.0 or update_interval 3.0. Obviously, the exact value depends on how up-to-date you need your data to be. On my Eee PC, changing the update interval doesn’t seem to have any adverse effect on the performance, so I usually set it to 1 second.

By default, Conky is designed to superimpose monitoring data directly onto your desktop (or as Conky’s documentation puts it, “draw to the root desktop window”).

This often causes Conky to flicker, which can be annoying. Conky has two options to help you to deal with this problem. The double_buffer setting lets Conky use the X double-buffer extension, which can eliminate flickering. If enabling double_buffer doesn’t help, you can use the own_window option, which forces Conky to run in a separate window. To enable these options, add them to the .conkyrc file:

double_buffer yes own_window yes

By default, Conky uses a monospaced font, but you can instruct it to use any font installed on your system by specifying the use_xft option followed by the xftfont setting. For example, if you wanted Conky to use the Bitstream Vera Sans 8pt font, the options would look like this:

use_xft yes xftfont Bitstream Vera Sans:size=8

The next step is to specify the Conky window’s settings, including its width, alignment, and default color. In the example below, the window width is set to 270 pixels, it uses white as its default color, and it is aligned to the top left corner.

maximum_width 270 default_color white alignment top_right

If you don’t want text in the Conky window to appear in all caps, use the uppercase option:

uppercase no

These are just a few of the configuration options that you can specify; check the list of all available Conky configuration options on Conky’s Web site.

With the basic display options in place, you can start working on what system parameters you want Conky to monitor by using so-called variables. For example, to display the kernel version of your system, you can use the kernel variable, and if you want Conky to show the hostname, you can do this by adding the nodename variable:

$nodename - $kernel

Note that each variable in the .conkyrc file is preceded by a $ sign. Conky also includes a few variables that allow you to control the appearance of the output. The color variable lets you specify text color, while the alignr variable allows you to right-justify text. To see how this works in practice, take a look at the following example:

${color lightgrey}Uptime:$color $uptime $alignr${color lightgrey}Load:$color $loadavg

The ${color lightgrey} sets the text color to light gray. To switch back to the default color (white), you can use the color variable without any parameter. As the name suggests, the uptime variable displays your machine’s uptime. As you can see from the example, you can combine several variables to achieve the desired effect. In this case, the $alignr${color lightgrey} variables are used to set color and right-justify text for the word “Load:” and the output of the loadavg variable, which displays the average processor load. In a similar manner, you can specify variables that display processor speed and CPU usage:

${color lightgrey}CPU: $color ${freq} Mhz $alignr${color lightgrey} Usage:$color $cpu%

Conky also allows you to visualize monitored data using graphs. The cpugraph variable, for example, displays the CPU usage as a graph. When used without any parameters, the graph is shown using default solid color, but you can use hex color values to specify gradients, which make the graph look much better:

${cpugraph 000000 ffffff}

You can use the memory-related variables to display the total amount of RAM (memmax), amount of memory in use (mem), and percentage of memory in use (memperc):

${color lightgrey}RAM usage:$color $mem/$memmax - $memperc%

You can also display these data as a bar graph using the membar variable: ${membar}.

When it comes to monitoring disk usage, you have a few variables to choose from, including fs_free (free space), fs_size (total size), and fs_bar (spaced used bar):

${color grey}Disk usage: $color${fs_free /} of ${fs_size /} ${fs_bar 6 /}

Finally, let's take a look at the variables that allow you to monitor wireless network connections. First, you have to find out the name of the network interface you want to monitor. To do this, you can use the bash ifconfig command, which returns a list of available network interfaces. Conky has quite a few variables that you can use to monitor the wireless connection, including:

  • wireless_essid (returns the ESSID name of the access point)
  • wireless_mode (returns the wireless mode, e.g. Managed/Ad-Hoc/Master)
  • wireless_bitrate (returns bitrate or speed, e.g. 11Mb/s)
  • wireless_link_qual (returns wireless link quality)
  • wireless_link_qual_perc (returns wireless link quality in percents)
  • wireless_link_bar (returns the wireless link quality displays as a bar)

Here is an example of how these variables can be used in the .conkyrc file:

${color #ffcb48}Wi-Fi ${hr 1} ${color lightgrey}Wireless signal: $color${wireless_link_qual ath0}% ${color lightgrey}IP address: $color${addr ath0}

If you want to monitor download and upload speeds, you can use the downspeedf and upspeedf variables (or downspeed and upspeed if you don't want to display the trailing decimal):

${color lightgrey}Download speed: $color${downspeedf wifi0} Kb/sec

There are also the downspeedgraph and upspeedgraph variables, which can display the download and upload speeds as graphs. And if you want to monitor the total amount of downloaded and uploaded data (handy if you are using a connection where you pay for transfered data), then you can use the totaldown and totalup variables:

${color red}Downloaded: $color${totaldown wifi0} $alignr ${color green}Uploaded: $color${totalup wifi0}

To summarize all the above, here is a sample .conkyrc configuration file you can use or tweak to fit your needs:

# .conkyrc update_interval 1.0 double_buffer yes own_window yes use_xft yes xftfont Bitstream Vera Sans:size=8 maximum_width 270 default_color white alignment top_right uppercase no TEXT $nodename - $kernel ${color lightgrey}Uptime:$color $uptime $alignr${color lightgrey}Load:$color $loadavg ${color lightgrey}CPU: $color ${freq} Mhz $alignr${color lightgrey} Usage:$color $cpu% $color${cpugraph} ${color lightgrey}Processor temperature: $color${acpitemp}°C ${color lightgrey}Battery: $color ${battery} ${color lightgrey}RAM usage:$color $mem/$memmax - $memperc% ${membar} ${color grey}Disk usage: $color${fs_free /} of ${fs_size /} ${fs_bar 6 /} ${color #ffcb48}Wi-Fi ${hr 1} ${color lightgrey}Wireless signal: $color${wireless_link_qual ath0}% ${color lightgrey}IP address: $color${addr ath0} ${color lightgrey}Download speed: $color${downspeedf wifi0} Kb/sec ${downspeedgraph wifi0} ${color red}Downloaded: $color${totaldown wifi0} $alignr ${color green}Uploaded: $color${totalup wifi0} ${color #ffcb48}Ethernet ${hr 1} ${color lightgrey}IP address: $alignr$color${addr eth0}

For more Conky goodness, visit the Conky thread in the Ubuntu forums.

Categories:

  • Tools & Utilities
  • System Administration