This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Tools & Utilities

Expert's guide to configuring Conky

By Dmitri Popov on June 02, 2008 (7:00:00 PM)

Share    Print    Comments   

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.

Dmitri Popov is a freelance writer whose articles have appeared in Russian, British, US, German, and Danish computer magazines.

Share    Print    Comments   

Comments

on Expert's guide to configuring Conky

Note: Comments are owned by the poster. We are not responsible for their content.

Expert's guide to configuring Conky

Posted by: Anonymous [ip: 149.165.11.46] on June 03, 2008 01:28 PM
here's what i put into my conkyrc to detect whether i'm using wired or wireless internet (or vpn). i imagine this could be cleaned up a bit, but it works quite well.

${if_empty ${exec cat /proc/net/arp | grep eth1}}${if_empty ${exec ps -e | grep pppd}}${alignc}${color white}wlan0: ${addr wlan0}$color
${alignc}${wireless_essid wlan0} (${wireless_ap wlan0})
${color 009900}${wireless_link_bar wlan0}$color
down: ${downspeed wlan0}k/s ${alignr}up: ${upspeed wlan0}k/s
total: ${totaldown wlan0} ${alignr} total: ${totalup wlan0}
${downspeedgraph wlan0 15,250 000000 000099} ${alignr}${upspeedgraph wlan0 15,250 000000 990000}
${else}${alignc}${color white}ppp0: ${addr ppp0}$color
down: ${downspeed ppp0}k/s ${alignr}up: ${upspeed ppp0}k/s
total: ${totaldown ppp0} ${alignr} total: ${totalup ppp0}
${downspeedgraph ppp0 15,250 000000 000099} ${alignr}${upspeedgraph ppp0 15,250 000000 990000}${endif}
${else}${alignc}${color white}eth1: ${addr eth1}$color
down: ${downspeed eth1}k/s ${alignr}up: ${upspeed eth1}k/s
total: ${totaldown eth1} ${alignr} total: ${totalup eth1}
${downspeedgraph eth1 15,250 000000 000099} ${alignr}${upspeedgraph eth1 15,250 000000 990000}
${endif}

#

Expert's guide to configuring Conky

Posted by: Anonymous [ip: 216.48.59.163] on June 03, 2008 07:14 PM
Yeah i was able to tolerate the flicker only so much. I switched back to gkrellm because of that and used the invisible theme. I liked conky cause of all the options and settings and little things i could add and customize but when i turned on double buffer is messed my xfce4 desktop up and cause the icons to dissapear. It did get rid of the flickering with conky though. And i dont want to run conky in its own window, i want it to look embeded in the desktop. Oh well maybe the nvidia, xfce, and conky gods will all work together harmoniously.

#

Expert's guide to configuring Conky

Posted by: Anonymous [ip: 83.27.134.59] on June 04, 2008 10:33 AM
You should have tried to use these lines:

own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

#

Expert's guide to configuring Conky

Posted by: Anonymous [ip: 212.84.98.122] on June 05, 2008 09:18 AM
Really good article Dimitri, nice and concise. I recently posted something similar on my blog at http://reddevil62-techhead.blogspot.com/, though my piece rambled a bit more than yours. I'm now using Conky on my main machine which runs Linux Mint 4.0 with Fluxbox as my window manager and it's a great combination - Conky for the details, Fluxbox for speed and Ubuntu repos for lots of applications. Thanks again for the article.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya