Conky is a tool I have used since about the time I started using Linux. It is a great piece of kit. When you first start using Conky it can be a bit overwhelming because it has a ton of options and configuring it is not terribly straight forward for those who do not like command line and editing files. But once you get over the initial hump it is amazing. It is a set and forget tool that I have used for years with very little modification once I had my initial set up. Here is what my current setup looks like:

I know what the different rings mean, but no one else does. So as a way of introduction the rings are as follows:

  1. Clock.
  2. Processor load (I have an i9 processor with 8 cores so that is why there are eight half concentric rings layered into one ring).
  3. Memory load (outside) | Battery charge (inside).
  4. Network traffic (left side outer is outbound via ethernet, left inner is inbound via ethernet, right side outer is outbound via wireless, right side inner is inbound via wireless) | Network ports (deep inner).
  5. Drives (percent used on various drives).

On this page you can see how my conky looks with other wallpapers.

Setting up Conky

In Ubuntu, Conky is in the main repositories so it is very straight forward to install:

$ sudo apt-get install conky

When the installation finishes you will be all set up. If you prefer a GUI to set up your conky with some pretty good looking initial themes, then I would encourage you to read this article over at WebUPD8 and follow the instructions for installing conky manager.

I prefer to fork and modify other people's open source code and so that is what the rest of this tutorial will work towards. To get an idea of the different things that you can do with conky I would encourage you to glance at the above article first, and then go over to DeviantArt and look through the Conky galleries. I originally did this but have heavily modified my theme which was originally based on work by LondonAli at DeviantArt. She has some beautiful conky themes she has built and her gallery is well worth pursuing.

If you find a theme which you like then you simply download the .zip file and extract it into your ~/.conky folder. Generally to do this, I right click on the Download link on the top of the right sidebar in DeviantArt, then Copy Link. After that, in terminal I type:

$ cd ~/.conky
$ wget -O conky.tgz $PASTE_LINK_WITH_CTRL_SHIFT_V
$ tar -xzvf conky.tgz

Or, if it is a zip download

$ cd ~/.conky
$ wget -O conky.zip $PASTE_LINK_WITH_CTRL_SHIFT_V
$ unzip conky

Once the files are extracted into your conky folder then you will want to cd into that directory and look at what you actually have. If all the files extracted into their own directory, I generally will move them back to the normal conky directory. Now, you are ready to start conky. I use the command line when I'm testing conky because you will be wanting to stop and restart it as you make hacks along the way.

In the command line again, the command to start conky is simple:

$ conky -c $CONKY_RC_FILE

Then, when you want to stop it you simply type CTRL+C when you are in your terminal. (By the by, ctrl+c in a terminal is cancel. This is why in terminal you need to type ctrl+SHIFT+c to copy something. This is a bit confusing and I've been thinking I need to change this default (which you can always do by modifying your shell config files) but haven't yet done it.)

When I was starting with Conky, I downloaded many conky configs from DeviantArt and then started conky with one, then stopped it and started it again with another, etc. until I found the one that I liked. So when you extract the archive you downloaded from DeviantArt usually you will want to see that the different conkyrc files have different names so that you can try different ones on your desktop.

On more sophisticated setups there are two files that conky will need, a conkyrc file which is the main file and a lua file which is used to draw cool shapes and sizes. Here is my conkyrc file. If you want to see my conky.lua file it is available here.

#--- Conkyrc, Originally by londonali1010, modified by compleatang ---#
background no
net_avg_samples 2
cpu_avg_samples 2
no_buffers yes
double_buffer yes
update_interval 1.0
default_color 467159

own_window yes
own_window_type normal
own_window_class conky
own_window_hints undecorated,skip_taskbar,skip_pager,sticky,below
own_window_transparent no
own_window_argb_visual yes
own_window_argb_value 0

border_inner_margin 0
border_outer_margin 0
default_outline_color white
default_shade_color white
draw_borders no
draw_graph_borders yes
stippled_borders 0
draw_outline no
draw_shades no
draw_shadows no
show_graph_scale no
show_graph_range no

use_xft yes
xftfont Sawasdee:size=24
xftalpha 0.8
uppercase no

minimum_size 1366 300
maximum_width 1366
use_spacer none
alignment tm
gap_x 0
gap_y 50

lua_load ~/.conky/conky.lua
lua_draw_hook_pre conky_widgets

TEXT
${voffset 100}${alignc}${time %A, %d %B %Y}

Once you have those installed and modified to your liking you are more or less all set.

Take Your Conky to the Next Level with Auto-Colors

I was interested in seeing if I could modify my conky to automatically pick colors that complement my wallpaper and I wanted it to run whenever I changed my wallpaper. This is a hack to be sure, but it works on Ubuntu at least. One of the things that Ubuntu (or Gnome, am not sure) does is when you tell it there is a new wallpaper but pick a file from a different location, it will copy that file into the ~/Wallpapers folder. I keep my wallpapers in my Dropbox so what I did was to set up a ruby process that watches the Wallpapers folder and when a new file is added, it modifies conky for me.

The ruby file is pretty straight forward, but to use it you will have to install two gems with gem install listen miro. After installing those gems, you are set.

#!/usr/bin/env ruby
require 'miro'
require 'listen'

# set defaults
@conky_rc_file = '/home/coda/.conky/conkyrc'
@conky_lua_file = '/home/coda/.conky/conky.lua'
watch_dir = '/home/coda/Wallpapers'

# miro options
Miro.options[:color_count] = 6
Miro.options[:resolution] = '1500x1500'

def get_colors(new_wallpaper)
  puts "getting colors for #{new_wallpaper}"
  colors = Miro::DominantColors.new(new_wallpaper).to_hex.sort

  @conky_txt_color_default = colors[1][1..-1]
  @conky_bg_color_default = colors[0][1..-1]
  @conky_fg_color_default = colors[3][1..-1]
end

def replace_colors_all text, bg, fg
  system("sed '-i' 's/default_color .*$/default_color #{text}/' #{@conky_rc_file}")
  system("sed '-i' 's/color_bg .*$/color_bg = 0x#{bg}/' #{@conky_lua_file}")
  system("sed '-i' 's/color_fg .*$/color_fg = 0x#{fg}/' #{@conky_lua_file}")
end

listener = Listen.to(watch_dir) do |modified, added, removed|
  if added.last
    get_colors(added.last)
    replace_colors_all(@conky_txt_color_default, @conky_bg_color_default, @conky_fg_color_default)
  end
end
listener.start
sleep

Since the conky deamon watches the conky files and will reload itself when the files are modified you do not have to add a restart command to restart conky. To make this run on startup and to stay running as a deamon in the background along with conky this is what I did. Another gem to install with gem install foreman. Then add a Procfile to the ~/.conky folder that looks like this:

conky_main: /usr/bin/conky -c /home/coda/.conky/conkyrc
conky_colors: /home/coda/.conky/conky_colorsd

Lastly, I added a custom startup script:

#!/usr/bin/env zsh
source ~/.zshrc
foreman start -f /home/coda/.conky/Procfile &

Once you add the startup script, you will need to make sure you can execute it with chmod +x startup.sh or whatever you call it. The final step is to call the startup script when you log into your computer by adding it to your Startup Applications. After that you are all set. The startup script will start foreman, which will start normal conky with the right conkyrc that you give to it and also the conky_colorsd deamon which will watch for wallpaper changes.

Further Customization

The conky_colorsd daemon is OK. But sometimes it gets the colors wrong. Also if I used a Wallpaper from the ~/Wallpaper folder (one I've used before) or from the standard Ubuntu wallpapers, the daemon will not see those changes and will not run the modification script. So I also built a conky_colors which is executable. I symlink this into my ~/.bin folder so that I can always call conky_colors from the command line. The process for conky_colors is roughly the same, it will look at the Wallpaper that currently is there, find its primary colors and then allow me to pick which colors I want to use for the text, ring forground and ring background.

There is one minor hiccup in the miro gem which does not do well parsing files that have spaces in them. So sometimes when you change to a wallpaper and nothing happens, it could be because of that, running the manual script should solve that process.

Voila! A completely wonderful system.

Want to Just Copy Me?

No problem as long as you have ruby installed on your system. Two steps and you're set:

  1. cd ~ && git clone https://github.com/compleatang/Conky.git .conky && gem install listen miro foreman
  2. Add ~/.conky/startup.sh to your Startup Applications

Happy Hacking!

~ # ~