Installing Conky on Ubuntu Gutsy

 

One of the joys of using Ubuntu in the workplace occurs every now and again when an XP user looks over my shoulder at the gloriousness of my compiz-enabled computers with my swishy rotating-desktop cube effects and eye-pleasing wobbly windows.

“Hey, can I get that on Windows” they ask – to which I say 'No!' before mocking them heartlessly with an especially evil laugh - the one that kinda goes “Mmmwa-har har har harrrrrr!” I then send them back to their creaking seven year old operating system with it's tired looking themes, single claustrophobic desktop and annoying yellow bubbles that pop up continually telling them their wireless signal is low...

... and now to rub it in even further, the Ubuntu funk just got funkier for I have discovered Conky!

I hadn't come across Conky in the last 18 months of Linux use and it is one of those apps that makes you wonder how you ever managed without it.... not because it's doing something terribly useful (at least, not for me), but because it can be used to make your Linux desktop look extra leet !

Now, although the joy of Conky had lain undiscovered thus far, I had been using gdesklets for some time. Various SideCandy apps provided various functions for me but on upgrading my Mac Mini to Hardy 8.04 Beta to see how it looked, I found one of my desklets was broken and I decided to see what else did a similar sort of job which is how I happened across Conky, the light weight system monitoring tool.

The strength of Conky is that it is sooooo configurable. There's no pointy-clicky interface which may put off people who are new to Linux but if you put the time and effort into setting it up for yourself then you can create a really cool looking desktop displaying information on pretty much anything – and you might just learn a bit about how your computer works in the process.

The best way to start with Conky is to visit the homepage and take a look at some of the screenshots...

http://conky.sourceforge.net/

From the Conky sourceforge page you can download the configuration file of one of the screenshots you like the look of and then tweak it until it's just right for your needs.

Now, I'm an Aquarian so (apparently) that's the reason I like the colour blue. This picture shows a screenshot of Conky running down the right hand side of my Vaio subnotebook screen (click to enlarge)...

 

scaled screenshot



This is my Conky configuration running in actual size:

Conky

 



A few things to point out about my own desktop before we begin. I'm basing this article on my Vaio subnotebook which has a small 28.4cm screen running a resolution of 1366x768, I have disposed of the bottom toolbar in Gnome and shoved the stuff I use onto the top toolbar panel (which as you can see is partially transparent). My Conky installation runs down the full length of the right side of my screen and you may think the Conky colours blend into the backround a bit but that is how I want it. To be honest, I run Conky just because it looks cool. Most of the information I'm actually displaying isn't terribly useful to me throughout the day so I don't need it standing out. Colours are easy enough to change though. BTW – the wallpaper is from DesktopNexus (see the Space/Planets category).

I'm going to run through the steps I took to get Conky running on this machine and you may use, change or ignore my configuration as you see fit! A word of warning though, Conky has a mountain of configurations, functions and options and I have tailored my installation specifically for my compiz-enabled laptop running Ubuntu 7.10 Gutsy.

First of all, use the Synaptic Package Manager to get Conky or from a command line issue the command:
sudo apt-get install conky

If you didn't open a command line terminal in the last step, open one now and create a Conky configuration file. General consensus seems to be that this config file should be in a hidden directory in your /home folder although this doesn't have to be the case. That's where mine is though so....

mkdir /home/[username]/.conky
nano /home/[username]/.conky/conkyrc


Obviously insert your user name where you see [username] !

You should now find yourself in the Nano text editor staring at a blank (new) file. This is where you need to put your conky configuration. You can either type in a customised configuration or you can copy and paste the contents of someone else's. There are plenty to choose from on the 'net including some from the Conky sourceforge page. My Vaio's configuration is listed below – feel free to copy and paste that if you want to use it as a starting point! Apologies for the small font size towards the end - it's an attempt to keep unwanted line wrapping to a minimum! Unfortunately some lines have wrapped in some browsers because of the formatting of this silly website. Text in cyan should not be line wrapped! Sorry!

#This is my Conky config file!
background yes
font 7x13
use_xft no
on_bottom yes

update_interval 1.0
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
double_buffer yes
minimum_size 280 5

draw_shades yes
draw_outline no
draw_borders no
stippled_borders 8
border_margin 4
border_width 1

default_color white
default_shade_color black
default_outline_color black

alignment top_right
maximum_width 330
gap_x 12
gap_y 25

no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale no
use_spacer yes

# stuff after 'TEXT' will be formatted on screen

TEXT
${color green} $nodename - $sysname $kernel on $machine
${color #5b6dad} Uptime:${color #7f8ed3} $uptime ${color #5b6dad}- Load:${color #7f8ed3} $loadavg
${color #5b6dad} CPU Frequency:${color #7f8ed3} $freq_dyn_g ${color #5b6dad} Maximum:${color #7f8ed3} $freq_g
${color #5b6dad} CPU Usage:${color #7f8ed3} $cpu% ${cpubar}
${color #000000}${cpugraph cpu0 32,330 000000 7f8ed3}

${color #5b6dad} RAM Usage:${color #7f8ed3} $mem/$memmax - $memperc% ${membar}
${color #5b6dad} Swap Usage:${color #7f8ed3} $swap/$swapmax - $swapperc% ${swapbar}

${color #5b6dad} Processes:${color #7f8ed3} $processes ${color #5b6dad}Running:${color #7f8ed3} $running_processes

${color #5b6dad}Networking (Wireless):
${color #5b6dad}Down:${color #7f8ed3} ${downspeed eth1} k/s${color #5b6dad}${offset 80}Up:${color #7f8ed3} ${upspeed eth1} k/s
${color #000000}${downspeedgraph eth1 32,165 000000 7f8ed3} ${color #000000}${upspeedgraph eth1 32,165 000000 7f8ed3}
${color #5b6dad}Address: ${color #7f8ed3}${addr eth1}${alignr}${color #5b6dad}TCP Connections: ${color #7f8ed3}${tcp_portmon 1 65535 count}


${color #5b6dad}Networking (Wired):

${color #5b6dad}Down:${color #7f8ed3} ${downspeed eth0} k/s${color #5b6dad}${offset 80}Up:${color #7f8ed3} ${upspeed eth0} k/s
${color #000000}${downspeedgraph eth0 32,165 000000 7f8ed3} ${color #000000}${upspeedgraph eth0 32,165 000000 7f8ed3}
${color #5b6dad}Address: ${color #7f8ed3}${addr eth0}${alignr}${color #5b6dad}TCP Connections: ${color #7f8ed3}${tcp_portmon 1 65535 count}


${color #5b6dad}File Systems:
${color #5b6dad}/ ${color #7f8ed3}${fs_used /}/${fs_size /} ${color #7f8ed3}${fs_bar /}
${color #5b6dad}/ ${color #7f8ed3}${fs_used /media/disk}/${fs_size /media/disk} ${color #7f8ed3}${fs_bar /media/disk}
${color #5b6dad}/ ${color #7f8ed3}${fs_used /media/disk-1}/${fs_size /media/disk-1} ${color #7f8ed3}${fs_bar /media/disk-1}


${color #5b6dad}Name PID CPU% MEM%
${color #7f8ed3} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color #7f8ed3} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color #7f8ed3} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color #5b6dad}Mem usage
${color #7f8ed3} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${color #7f8ed3} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${color #7f8ed3} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}


${color #5b6dad}Port(s)${alignr}#Connections
${color #7f8ed3}Inbound: ${tcp_portmon 1 32767 count} Outbound: ${tcp_portmon 32768 61000 count}${alignr}ALL: ${tcp_portmon 1 65535 count}
${color #5b6dad}Inbound Connection ${alignr} Local Service/Port${color #7f8ed3}
${tcp_portmon 1 32767 rhost 0} ${alignr} ${tcp_portmon 1 32767 lservice 0}
${tcp_portmon 1 32767 rhost 1} ${alignr} ${tcp_portmon 1 32767 lservice 1}
${color #5b6dad}Outbound Connection ${alignr} Remote Service/Port${color #7f8ed3}
${tcp_portmon 32768 61000 rhost 0} ${alignr} ${tcp_portmon 32768 61000 rservice 0}
${tcp_portmon 32768 61000 rhost 1} ${alignr} ${tcp_portmon 32768 61000 rservice 1}
${tcp_portmon 32768 61000 rhost 2} ${alignr} ${tcp_portmon 32768 61000 rservice 2}

${color 5b6dad}Logging ${hr 2}${color #7f8ed3}

${execi 30 tail -n2 /var/log/messages | fold -w47}


Read the Important Points section of this article before modifying the configuration! Before then though, continue with the Conky installation by saving your changes and exiting once you've finished in Nano (CTRL-O, CTRL-X).

You can now start Conky from the command line by entering the following:

conky -c /home/[username]/.conky/conkyrc -d

See how is looks. Don't like it?? Stop Conky by entering the command sudo pkill conky and then tweak the config file with whatever changes you want to try before starting it again.


Important Points!

You probably know that generally text in config files which follow a hash (#) are comments inserted for reference only and are ignored by the computer. This is also the case for our Conky file up to the line which reads TEXT. If you're fiddling with your Conky configuration file, do not insert comments or hash characters after the TEXT line as they will be executed by Conky and will probably result in your comments or hash signs appearing in your beautifully crafted Conky layout!

My File Systems section is set to display details about my hard drive and two removable drives (/media/disk and /media/disk-1). These are the mount points assigned to USB flash-drives and SD cards that I use. If your computer uses different mount points, amend this section accordingly. You can also add the if_mounted parameter so that these drives don't show in Conky unless they are actually mounted. I haven't enabled this in my configuration but if you want to do it then amend the drive mount lines so they read similar to the example below:

${if_mounted /media/disk}${color #5b6dad}/ ${color #7f8ed3}${fs_used /media/disk}/${fs_size /media/disk} ${color #7f8ed3}${fs_bar /media/disk} $endif

By the way, when running from the command line you may get errors about every 15 seconds along the lines of:
Conky: statfs '/media/disk-1': No such file or directory
Conky: statfs '/media/disk': No such file or directory


Conky will show these errors in the terminal window it was started from even if you use the if_mounted statement. For this reason, you will probably want to start Conky automatically at log in so the errors don't bug you. How to do this is mentioned at the end of this article.

My config file monitors two network interfaces, eth0 (wired) and eth1 (wireless). Use the ifconfig command to find out how your network interfaces are named as they may differ (e.g. eth2, ath0, wifi0, etc.)

The width of my Conky window is 330 pixels as set in the line maximum_width 330. The networking sections each have two graphs, one for download and one for upload. The size of these graphs has been set in my config to 165 pixels each (half of 330). If you modify the width of your Conky window then you'll need to amend the size of the graphs so that they look right. The line below shows the graph sizes for the eth1 interface (each graph 32 pixels high, 165 pixels long):
{color #000000}${downspeedgraph eth1 32,165 000000 7f8ed3} ${color #000000}${upspeedgraph eth1 32,165 000000 7f8ed3}


Similarly, the CPU processor graph size is set to 330 pixels in the following line and this will need to be amended if you change the width of your Conky window.
${color #000000}${cpugraph cpu0 32,330 000000 7f8ed3}

My config is set to display two incoming and three outgoing network services such as ssh, samba, irc, etc. To display more, simply add extra lines in these sections and increment the rhost and rservice values.

If you want more lines displayed in the Logging section, amend the following line which is set to display the last two logged events in my config (as that's all I could fit into the physical screen space). My config is also set to line wrap the text after 47 characters but you can make this smaller or larger to fit your window size if different.
${execi 30 tail -n2 /var/log/messages | fold -w47}

A full list of variables is available here:
http://conky.sourceforge.net/variables.html

So have a play!

One last thing, how to start Conky automatically when you log in to Gnome....

Create a startup script in your home directory:
nano /home/[username]/conkystart.sh

Populate the config file with the command to start Conky in daemon (background) mode and to use your configuration file:

#!/bin/bash
#Starts conky
sleep 20 #May not be required, see below
conky -c /home/[username]/.conky/conkyrc -d


The 'sleep for 20 seconds' parameter is needed on my laptop to ensure Conky loads after the desktop starts. Other installations may not require this or may need a different sleep delay.

Save changes and exit Nano (CTRL-O, CTRL-X).

Make the startup script executable:
chmod +x /home/username/conkystart.sh

Click on System / Preferences / Sessions and click Add to add a new entry. Set the entry as below:
Name: Conky
Command: /home/[username]/conkystart.sh
Comment: Starts Conky

Click OK and Close.

Now when you log in to Gnome, Conky should start automatically.

Problems???? Check Ubuntu forums. They have several threads on Conky including this monster:
http://ubuntuforums.org/showthread.php?t=205865&highlight=conky

Oh, and while I'm on the subject of eyecandy installations to make your XP co-workers cry like little girls, if (like me) you find gnome-screensaver missing some of the configuration options you would like, try replacing it with xscreensaver. Take a look at the homepage here: http://www.jwz.org/xscreensaver/