Display System Info On Your Raspberry PI Using Conky

Display System Info Using Conky

There is a tool called Conky that allows you to display system information on your desktop and the information that is displayed is customisable to your needs.

In this tutorial I am going to show you how to install Conky, how to get it to run when your Raspberry PI boots and how to configure Conky to display key pieces of information such as the date and time, the temperature the PI is running at, the CPU usage and RAM usage, how much of your file system is used and network usage.

1. Install Conky

To install conky open a terminal window by pressing CTRL, ALT and T at the same time on your keyboard.

Now type in the following command:

sudo apt-get install conky

2. Run Conky Manually

To see if conky has installed successfully run Conky using the following command

conky -b &

Conky is set to update the details on the screen at regular intervals. This can cause the screen to flicker.

The -b uses double buffering which eliminates the flicker.

The ampersand (&) runs the process as a background task.

3. Creating a config file

Conky runs using a default configuration file. If you want to customise the settings then you will need to create your own conky file.

There are 2 ways to do this. The first way is to copy the existing config and then adjust what you need and the second way is to simply create an empty config file.

I will show you both ways here so that you can decide what you want to do.

3.1 Create an empty config file

Open a terminal window and run the following command:

cd ~/.config

The ~ can be entered by pressing the shift and # key on a Raspberry PI 400 keyboard.

Alternatively you can type the following command:

cd /home/pi/.config

To create the conky configuration file type the following command:

touch .conkyrc

3.2 Copy an existing config file

To copy an existing config file open a terminal and run the following command

sudo cp /etc/conky/conky.conf /home/pi/.config/.conkyrc

You now need to change the owner to your user by running the following command

sudo chown pi /home/pi/.config/.conkyrc

4. Kill Conky

If conky is already running cancel it. You can usually do this just by clicking on it on the desktop.

If this doesn’t work, run the following commands to find and kill conky.

To find the running conky process:

ps -ef | grep conky

The process you need to kill is the one that has the executable pointing at /usr/bin/conky. In the screenshot above you will see the process ID for my conky process is 652.

Now run the following command to kill conky

kill -9 652

An alternative way to kill conky is to type the following into the terminal:

xkill

This will give you a cross hair. Now simply click on the conky window and it will terminate.

5. Configure Conky Display

This section deals with the positioning and display of conky. Step 7 will deal with the actual details of what is displayed.

Open a terminal window and run the following command to edit your config file:

sudo nano /home/pi/.config/.conkyrc

NOTE: If during this guide you find nano too difficult to use then replace nano with mousepad as follows:

sudo mousepad /home/pi/.config/.conkyrc

The very minimum that your conky configuration file needs is as follows:

conky.config = {
}

conky.text = [[
]]

The conky.config section deals with the positioning of conky and the look and feel.

The conky.text section deals with the contents that are displayed in the conky window.

If you copied the default conky config file then you will already have these sections. If you created a brand new file then you won’t.

Make sure your config file has a conky.config and conky.text section by selecting the text above, copying it and pasting it into your nano window. (To paste into nano, right click and choose paste).

To save the file press CTRL and O.

To run conky with your conky file, open a new terminal window and enter the following command:

conky -b -c /home/pi/.config/.conkyrc &

This runs conky as before but the -c uses the path provided to select your conky configuration settings.

You will notice that if you do this with an empty config file that nothing really happens.

Let’s add some bare bones to get started.

conky.config = {
own_window = true,
double_buffer = true,
use_xft = true,
font = 'Droid Sans Mono:size=11'
}

conky.text = [[
${time %H:%M}
]]

The own_window is a true or false setting. Setting this to true will cause your conky settings to display in their own window.

You will also need to set a default font, use_xft allows you to use anti-aliased font and the font setting is the font I selected.

You can see a list of available fonts by running the following command in a terminal window:

fc-list | more

The double_buffer prevents flickering.

Finally I have added a line to the conky.text to display the time so there is something to display.

If you copy and paste the text into your config file you will now see a small box in the bottom left corner of the screen, displaying the time.

You can change the position of the box.

conky.config = {
own_window = true,
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right'
}

conky.text = [[
${time %H:%M}
]]

The alignment can be set to any of the following values:

  • top_left
  • top_right
  • top_middle
  • bottom_left
  • bottom_right
  • bottom_middle
  • middle_left
  • middle_right
  • middle_middle

You can adjust the position further by using gap_x and gap_y.

conky.config = {
own_window = true,
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,

}

conky.text = [[
${time %H:%M}
]]

The gap_x leaves a gap of n pixels where n is the value of gap_x. Therefore if you set the alignment to top_right and set gap_x to 100, the window would be indented 100 pixels from the right of the screen.

The gap_y works in the same way but vertically. If you have the alignment set to top_right and set gap_y to 100, the window would be indented 100 pixels from the top.

You can force the window to be a certain height and width using the minimum and maximum height and width settings.

conky.config = {
own_window = true,
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${time %H:%M}
]]

If you set the minmum and maximum width to be the same value and the minimum and maximum height to the same value then the size of the box remains consistent regardless of the contents of the box.

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_colour = 'ffffce',
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${time %H:%M}
]]

The own_window_title setting lets you change the title of the conky window.

You can change the background colour of the window by setting own_window_colour to a hex value. The hex value is 6 characters. The first 2 characters are for red and go from 00 to FF, the second 2 characters are for green and the last 2 characters are for blue. (Note that the spelling of colour is colour and not color).

To make things confusing to default the text colour you can use the default_color setting to a hex value. (Note color, not colour).

You can make the window transparent simply by adding the follow line:

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_transparent = true,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${time %H:%M}
]]

Note that to add transparency I have added own_window_transparent = true but I also removed the own_window_colour.

There is a better way to achieve transparency but it is a little more involved and therefore will be covered in its own section later on.

There are different window types that can be used with conky as follows:

  • normal – this makes conky act like a normal application window. It appears in the taskbar and you can minimise, maximise, close and drag the window around
  • desktop – this locks the conky window to the desktop and contains no controls.
  • dock – when I tried this it docked conky to the top left corner. Not sure how useful this is or why it exists
  • panel – seems to do exactly the same as panel
  • override – this lets you override the window manager

The only 2 I have ever found useful are normal and desktop.

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_transparent = true,
own_window_type = 'desktop',
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${time %H:%M}
]]

There are a number of other configuration options available and you can view them by typing the following into a terminal window:

man conky

6. Conky Real Transparency

In the previous section I showed how to add transparency using the own_window_transparent option which works but makes your text difficult to see.

A better option is to use a coloured background and then add opacity.

To do this you need to add the following lines:

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_argb_visual = true,
own_window_argb_value = 100,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${time %H:%M}
]]

The own_window_argb_visual determines whether argb visuals can be used or not. The own_window_argb_value is a number between 0 and 255. 0 = completely transparent, 255 = opaque.

You will notice when you try this on a Raspberry PI that it doesn’t work straight away and that is because the compositing manager isn’t running.

To prove this point open another terminal and type the following command:

xcompmgr &

Transparency should now start working.

Obviously you don’t want to have to type this command every time your computer boots, so you can add it to the autostart as follows.

Within a terminal window type the following command:

cd /etc/xdg/lxsession/LXDE-pi

Now open the autostart file in nano by typing the following command:

sudo nano autostart

Add a new line and type the following so that the file looks something like this:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
xcompmgr

Save the file by pressing CTRL and O and press return.

Exit nano by pressing CTRL and X

When you reboot your computer the transparency should now work automatically.

7. Configuring Conky Output

Thus far we have looked at how to configure the look and feel of Conky but we haven’t looked at what is actually displayed to the screen.

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_argb_visual = true,
own_window_argb_value = 100,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${time %H:%M}
]]

Everything you want to display on the screen is added within the [[ and ]] of conky.text.

The simplest thing you can add is plain text. For example

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_argb_visual = true,
own_window_argb_value = 100,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
Hello World
]]

The colour of the text will be whatever you set default_colour to in the config settings.

You can change the colour of the text by using the color variable as follows:

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_argb_visual = true,
own_window_argb_value = 100,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${color ff0000}Hello World
]]

The variable starts with a $ and then has curly braces ${}. In between the braces is the word color and then the hex value for the colour.

You can align the text using the following variables.

  • left alignment = no parameter required
  • centre alignment = alignc
  • right alignment = alignr

For example:

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_argb_visual = true,
own_window_argb_value = 100,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${alignc}Hello World
]]

You can change the font by using the font variable as follows:

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_argb_visual = true,
own_window_argb_value = 100,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
${font Droid Sans Mono:pixelsize=36}Hello World${font}
Goodbye World
]]

The variable name in this case is font. Without supplying a font name, the default font is used but you can supply a font name and then a pixelsize as shown in the example.

In the example the words “Hello World” are printed using the Droid Sans Mono font using size 36 and then “Goodbye World” is displayed using the default font.

Displaying plain text isn’t very useful. The whole point of conky is to output useful system information and there are a whole host of variables that can be used.

Let’s start with your IP Address.

The variable to use for IP address is ${addr}. The ${addr} variable requires a network interface and for the Raspberry PI this is always wlan0. So we can output the IP address as follows:

conky.config = {
own_window = true,
own_window_title = 'System Info',
own_window_argb_visual = true,
own_window_argb_value = 100,
default_color = '000000',
use_xft = true,
font = 'FreeSansBold:size=16',
alignment='top_right',
gap_x = 50,
gap_y = 60,
minimum_width = 300,
maximum_width = 300,
minimum_height = 400,
maximum_height = 400
}

conky.text = [[
IP Address: ${addr wlan0}
]]

Note that this returns your internal IP address.

Knowing how much CPU is being used is also very useful and there are various ways to display this information.

The most straight forward is as follows:

conky.text = [[
CPU: ${cpu}%
]]

This displays your CPU usage as a percentage.

You can also use the following to show the same information in a bar.

conky.text = [[
CPU: ${cpu}% : ${cpubar}
]]

Another option is ${cpugauge} which shows the cpu much like your car’s speedometer.

More useful than ${cpugauge} is ${cpugraph} which lets you see CPU usage over time.

conky.text = [[
CPU: ${cpu}% : ${cpubar}
${cpugraph 100,250}
]]

The cpugraph variable has the following parameters that can be specified with it.

  • height
  • width
  • gradient colour 1
  • gradient colour 2
  • scale

There are dozens of variables available and here are a list of some of the more useful ones.

  • ${addr} – displays IP address
  • ${cpu} – displays CPU usage as a percentage
  • ${cpubar} – displays CPU usage as a bar chart
  • ${cpugraph} – displays CPUS usage over time
  • ${diskio} – displays disk input/output
  • ${diskiograph} – displays disk activity as a graph over time
  • ${downspeed} – download speed
  • ${downspeedgraph} – download speed as a graph over time
  • ${freq_g} – CPU frequency in GHZ
  • ${fs_bar} – How much space is used on a file system as a bar chart
  • ${fs_bar_free} – How much space is free on a file system as a bar chart
  • ${fs_free} – How much space is free on a file system
  • ${fs_free_perc} – How much space is free as a percentage
  • ${fs_size} – How big is the file system
  • ${fs_type} – What type is the file system
  • ${fs_used} – How much of the file system is used
  • ${fs_used_perc} – How much of the file system is used as a percentage
  • ${hr} – displays a horizontal line
  • ${hwmon} – hwmon sensor. Useful for displaying system temperature – Temp: ${hwmon 0 temp 1} C
  • ${kernel} – displays the kernel version
  • ${mem} – Amount of memory in use
  • ${membar} – Memory used as a bar chart
  • ${memfree} – Amount of free memory
  • ${memgauge} – Amount of memory used as a gauge
  • ${memgraph} – Amount of memory used as a graph over time.
  • ${memmax} – Total amount of memory
  • ${memperc} – Total amount of memory used as a percentage
  • ${nodename} – Host name of the computer
  • ${nodename_short} – Short version of the computer host name
  • ${offset} – shift text by number of pixels – i.e. ${offset 10} shifts the text 10 pixels to the right
  • ${swap} – amount of swap in use
  • ${swapbar} – swap used as a bar chart
  • ${swapfree} – how much swap space is free
  • ${swapmax} – maximum amount of swap space
  • ${swapperc} – swap usage as a percentage
  • ${tab} – Adds a tab space
  • ${time} – Shows the time
  • ${upspeed} – Shows the upload speed
  • ${uptime} – Shows how long the PI has been running
  • ${voffset} – Moves the pixels down by the value specified. Similar to offset but vertically not horizontally
  • ${wireless_essid} – Shows the network name

There are more variables than the ones listed. You can find more information about their usage by typing the following into a terminal window:

man conky

8. Run Conky At Startup

To get conky to run at startup open a terminal window (press ctrl, alt and t at the same time).

Type the following command:

cd /etc/xdg/autostart

Open a new file using nano as follows:

sudo nano conky.desktop

Paste the following text into the file: (select the text, press ctrl and c and then within nano right click and choose paste)

[Desktop Entry]
Type=Application
Name=conky
Comment=runs conky
NoDisplay=true
Exec=conky -b -c /home/pi/.config/.conkyrc
NotShowIn=GNOME;KDE;XFCE;

Save the file by pressing CTRL and O and then press return.

Exit nano by pressing CTRL and X.

To check it works reboot your Raspberry PI

sudo reboot now

Sample Conky File

conky.config = {
    alignment = 'top_right',
    double_buffer = true,
    default_color='000033',
    use_xft = true,
    font = 'Droid Sans Mono:size=11',
    gap_x = 50,
    gap_y = 60,
    maximum_width = 300,
    minimum_width = 300,
    own_window = true,
    own_window_colour = 'ffffce',
    own_window_type = 'normal',
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager'
}

conky.text = [[
${alignc}${font Droid Sans Mono:pixelsize=40}${time %H:%M}${font}
${voffset 5}${alignc}${font Droid Sans Mono:pixelsize=15}${time %A %d %B %Y}${font}
${hr}
${color black}Temp:$color ${hwmon 0 temp 1} C
${color black}Uptime${color} : $uptime
${color black}CPU${color} : $freq_g GHZ
${cpu}% ${cpubar}
${cpugraph 60,299 000000 ff0000 -t}
${color black}RAM${color} : ${mem} / ${memmax}
${memperc}% $membar
${memgraph 60,299 000000 ff0000 -t}
${hr}
${color black}File systems:${color}
${color black}/ ${color}${fs_used /} / ${fs_size /}
${fs_bar /}
${color black}/home ${color}${fs_used /home} / ${fs_size /home} 
${fs_bar /home}
${hr}
${color black}Network:${color} ${voffset -1}${font :size=9}${color black}${addrs wlan0} 
${voffset 5}${template1}  ${downspeedf wlan0} kB/s ${goto 145}${template0} ${upspeedf wlan0} kB/s
${downspeedgraph wlan0 60,144 000000 ff0000 -t} ${upspeedgraph wlan0 60,144 000000 ff0000 -t} 
${color black}ESSID:${color}  ${wireless_essid wlan0}
]]

The text above is a sample config file and outputs many useful pieces of information. You can use this as a starting point and amend as required.