Wednesday, June 30, 2010

Setting Up Conky on Ubuntu


Conky is a pretty cool desktop app that displays system monitoring information.  I began using it months ago and recently had to go through setting it up again when I did a fresh install of Ubuntu 9.04 on my laptop.  Yes, 9.04.  For some reason 9.10 just didn't seem to agree with me.  Anyway, the following steps are specific to Ubuntu 9.04.  You may need to do some tweaking to use it on your version of Ubuntu.  Steps for installation and set-up on distros based on anything other than Ubuntu will vary.

First, install Conky either through Synaptic (simply look up "conky") or via command line with the following:

sudo apt-get --assume-yes install conky

Second, make a configuration file in your home directory. This is where you will put the code for what you want displayed on your conky desktop.

gedit /home/your_user_name/.conkyrc

Third, insert the code for your conky display. There are many options made available online by more knowledgeable minds than mine, but the following is what I use.  I adapted it from something I found on the Ubuntu forums (see here)  You can copy and paste it into the conkyrc file you should still have open. Once you've done this, save and close the file.
Code:
# UBUNTU-CONKY
# A comprehensive conky script, configured for use on
# Ubuntu / Debian Gnome, without the need for any external scripts.
#
# Based on conky-jc and the default .conkyrc.
# INCLUDES:
# - tail of /var/log/messages
# - netstat shows number of connections from your computer and application/PID making it.

# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# fiddle with window
use_spacer right

# Use Xft?
use_xft yes
xftfont DejaVu Sans:size=8
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 1.0

# Minimum size of text area
# minimum_size 250 5

# Draw shades?
draw_shades no

# Text stuff
draw_outline no # amplifies text if yes
draw_borders no
uppercase no # set to yes if you want all text to be in uppercase

# Stippled borders?
stippled_borders 3

# border margins
border_margin 9

# border width
border_width 10

# Default colors and also border colors, grey90 == #e5e5e5
default_color grey

own_window_colour brown
own_window_transparent yes

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
gap_x 10
gap_y 40

# stuff after 'TEXT' will be formatted on screen

TEXT
$color
${color blue}SYSTEM ${hr 2}$color
$nodename $sysname $kernel on $machine

${color red}CPU ${hr 2}$color
${freq}MHz Load: ${loadavg} Temp: ${acpitemp}
$cpubar
${cpugraph 000000 ffffff}
NAME PID CPU% MEM%
${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}

${color green}MEMORY / DISK ${hr 2}$color
RAM: $memperc% ${membar 6}$color
Swap: $swapperc% ${swapbar 6}$color

Root: ${fs_free_perc /}% ${fs_bar 6 /}$color
hda1: ${fs_free_perc /media/sda1}% ${fs_bar 6 /media/sda1}$color

${color grey}NETWORK (${addr eth0}) ${hr 2}$color
Down: $color${downspeed eth0} k/s ${alignr}Up: ${upspeed eth0} k/s
${downspeedgraph eth0 25,140 000000 ff0000} ${alignr}${upspeedgraph eth0
25,140 000000 00ff00}$color
Total: ${totaldown eth0} ${alignr}Total: ${totalup eth0}
${execi 30 netstat -ept | grep ESTAB | awk '{print $9}' | cut -d: -f1 | sort | uniq -c | sort -nr}
${color orange}LOGGING ${hr 2}$color
${execi 30 tail -n3 /var/log/messages | awk '{print " ",$5,$6,$7,$8,$9,$10}' | fold -w50}
Fourth, create a bash script for starting Conky when the computer boots up.

gedit .conky_start.sh

Place the following code in the new file you have created, then save and close.


#!/bin/bash

sleep 2 && conky;


Do the following to ensure that the file is executable:


chmod a+x .conky_start.sh

Fifth, add the conky start script to "Startup Applications" (System > Preferences > Startup Applications).


The command is located at /home/your_user_name/.conky_start.sh

Sixth, restart your computer and enjoy Conky.  Play around with the config file if you want to change colors or other settings.  As I mentioned above, there are other codes mashed together out there on the Internet that you can use for a different look.  Mine isn't definitive, by any stretch.

0 comments:

Post a Comment