Viewing system information with Conky

Modern desktops try to make the user's work with the computer as pleasant as possible. In the short term, you reach only for the PC features that you really need in daily life, and developers mostly hide the detailed information about the system. However, if you need quick information about the free space on a hard drive, for example, you'll likely have search for the information.

That's where the Conky [1] system monitor comes in handy. It displays just about all the information you need in a desktop widget (Figure 1). You can configure the display as you like and position it anywhere on the desktop.

Figure 1: Right after installation, and with no more than basic configuration, Conky is ready to provide helpful information about your system.

Conky doesn't come with a graphical interface for configuration, and you need a configuration file to adjust the application. However, the additional conky-colors script lets you enter configuration commands without having to edit the file manually.

From a terminal, use the conky command to start the program. Conky looks somewhat busy in its basic configuration (Figure  1), so customizing it is a natural first step.

You don't need to start from scratch, though – just use the /etc/conky/conky.conf system-wide configuration file as a basis for further customization by copying the file to your user directory, renaming it .conkyrc , and then opening it in your favorite text editor.

Manual Adjustments

The configuration file is divided into two parts. One part contains program parameters, such as the desktop window size and the colors and frames used. The second part, introduced by the simple keyword TEXT , is where you configure what data the application outputs.

In testing, the Conky display flickered after startup if a window was on top of it. If this happens to you, add the double_buffer yes line to the first part of the configuration file. If this doesn't fix the problem, you can always have Conky operate in a separate window. To do this, enter the line own_window yes in the configuration file. After saving the file, the software usually detects a change in the configuration file. If not, restart Conky.

As you can see from the aforementioned configuration settings, each individual setting is made up by a name-value pair. Using the options, it's easy to customize the system monitor visually to your needs. You can dramatically change its look with just a few settings.

The settings in Listing 1 make Conky look like Figure 2. With own_window_transparent yes , you can make the widget semi-transparent, in which case the software adds an image of the desktop wallpaper behind it. To customize the font, use use_xft yes and xftfont Arial . You can use any font installed on the system.

Listing 1

Appearance

01 alignment bottom_right
02 gap_x 40
03 gap_y 40
04 use_xft yes
05 xftfont Arial
06 own_window_transparent yes
Figure 2: With just a few simple steps in Conky, you can make visual adjustments to your desktop.

The alignment option lets you set the widget's position on the desktop. In the example, it's set to bottom_right . The values after gap_x and gap_y specify the widget's distance from the screen edge, which is 40 pixels in the example. Other options are listed in Table 1, with the complete list of options given on the website [2].

Apart from display options, you can add specific output options to the TEXT part of the configuration file, such as the number of new email messages or the temperature units. A description for some of these options is shown in Table 2, with a complete list on the web [3].

Customizing Output

The Conky output options are set in the TEXT part of the .conkyrc configuration file. Apart from basic information about the system (e.g., processor, hard disk, and main memory utilization), Conky can also report on such things as battery usage, IP addresses, component temperatures, RSS feeds, and mail notifications. Listing 2 details an example of one solution, with the corresponding display shown in Figure 3.

Listing 2

Displayed Information

01 TEXT
02 $alignr ${color grey}System Data $color
03 Processor $color $hr
04 ${color grey}CPU Clock Rate:$color $freq_g GHz
05 ${color grey}CPU Usage:$color ${cpubar 12,100} $cpu%
06
07 Hard Disk $color $hr
08 $color${fs_used /} of ${fs_size /} used - ${fs_used_perc /}%
09 ${fs_bar 12 /}
10
11 RAM $color $hr
12 $mem of $memmax used - $memperc%
13 ${membar 12}
Figure 3: With very little effort, Conky shows you customized information on the screen.

Variables are used for outputting values, as indicated by dollar signs, such as $machine . Assigning option-value pairs requires curly braces, such as ${color grey} .

CPU usage is displayed via the $cpu variable, which shows the value as a percentage by default for all processors. To output a value for a specific processor, add the CPU number to the variable, such as ${cpu cpu1} for the first processor.

To make the percentage values more pronounced, Conky provides several graphical elements. Among these are bar charts that you can activate with the $cpubar variable. By entering height and width values, you can tell the program what size to make the bar. Specifying ${cpubar 12,100} outputs the bar with a height of 12 pixels and a width of 100 pixels.

Output of hard disk usage is through the $fs_used variable. Combined with $fs_size , it generates output about the ratio of total disk space to that actually used (line 8 in Listing 2).

By including a slash for the root filesystem (${fs_used /} ), the program evaluates the mounted filesystem at the corresponding spot. As with processor details, Conky can also display the hard drive data as a bar if you specify the $fs_bar variable.

Main memory output uses similar variables. Use $mem and $memmax to show the actual memory used compared with the maximum available, and the $membar variable displays it as a bar.

Conky-Colors

The Conky-colors [4] script simplifies the configuration in that it makes modifications to the configuration file unnecessary. Instead, you create a configuration with specified options right on the command line. However, it's recommended that you save your customized configuration file under a different name  – just in case.

To get started with conky-colors , you need to prepare your system to use the software, as shown in Listing 3. While installing the hddtemp package, the script asks you whether you want to start the service at system startup. The third step is to respond to all setup questions with yes . The example in Listing 3 specifies which sensors you want to monitor.

Listing 3

conky-colors Setup

$ sudo apt-get install aptitude python-statgrab python-keyring ttf-ubuntu-font-family hddtemp curl lm-sensors conky-all
$ sudo chmod u+s /usr/sbin/hddtemp
$ sudo sensors-detect

To download the source files from deviantART, click Download File down the right pane of the web page [4]. Then, unpack the downloaded ZIP file to the directory of your choice and open a console; use cd to change to the directory, and enter the following commands:

$ make
$ sudo make install

With a few simple commands, you can configure the system monitor. To open help pages, use the command:

$ conky-colors --help

The conky-colors --lang=en command is enough to get you started. It creates a configuration in English. The script then asks whether you want an Ubuntu or Debian-like distribution, and you respond with y or n . The program creates the corresponding configuration when you enter the command:

$ conky -c /home/<username>/.conkycolors/conkyrc

Conky-colors accepts several options. The following command extends the configuration, with output of the network load and a calendar, and applies a theme to the layout:

$ conky-colors --lang=en --network --calendar --theme=ambiance

You then need to restart Conky. The --lang=en option again specifies output in English.

Conky-colors provides different color schemes to match the output to your desktop (Figure 4). Using ./conky-colors --help you can find under Themes all the available options, among them brave , carbonite , noble , or simply blue or red . You need to select only one item with the --theme=<theme_name> option.

Figure 4: Conky-colors lets you easily create chic views of important system information.

Using Cairo

Conky-colors customization is not limited only to colors. The tool includes a theme called cairo with which you can further beautify your output (Figure 5). The following command is an example:

Figure 5: The Cairo theme displays visually eye-catching circular diagrams.
$ conky-colors --cairo --lang=en --network --theme=ambiance

Alternatives to the Cairo theme include --slim for a display across the entire screen (Figure 6). The command to activate this theme is:

Figure 6: Use the --slim option to generate this output.
$ conky-colors --slim --lang=en --w=1920 --h=1080

The sls theme not only looks nice but also provides weather information. Include your location code in the command – for example:

conky-colors --sls --lang=en --weather=<Weather code> --theme=blue

You can extract your location code from the web [5]. For example, USNY0096 is one location code for New York.

Conclusion

Conky provides many opportunities to be creative with the use of simple commands to create your own desktop widget. The lack of a graphical user interface is difficult at first, but the configuration follows a defined schema that produces results quickly. Thanks to conky-colors , you can avoid messing around constantly with a configuration file.

Installation

Because of its popularity, Conky can be found in the repositories of all major distributions, so you only need to set it up with the respective administration tools.

Ubuntu users can install Conky easily from the Software Center by searching for conky . You can choose among the conky-all , conky-std , and conky-cli packages; the last choice is mostly suited for use on servers. Alternatively, you can integrate Conky with the sudo apt-get install conky command.

Table 1

Display Options

Option Description
alignment Position on the screen (top_left , top_right , top_middle , bottom_left , bottom_right , bottom_middle , middle_left , middle_middle , middle_right , none )
border_width Width of the border in pixels
default_color Default widget and border color
use_xft Enable smooth (anti-aliased) fonts (yes /no )
xftfont Font used
draw_borders Enable borders around text (yes , no )
maximum_width Maximum width of the widget in pixels
minimum_size Minimum size of the widget in pixels
border_inner_margin Inner border margin between border and text in pixels
uppercase Use uppercase characters only (yes /no )

Table 2

Output Options

Option Description
machine Processor architecture
color Changes the color of the output (e.g., ${color grey} )
freq_g CPU frequencies in GHz (${freq_g 1} shows the value for the first processor)
freq CPU frequencies in MHz (${freq 1} shows the value for the first processor)
cpu CPU usage as a percentage (${cpu cpu0} shows total usage for all CPUs)
cpubar CPU shown as a bar (${cpubar 12,100} shows a bar with height=12, width=100 pixels)
fs_used Space used by the filesystem
fs_size Total size of the filesystem
fs_bar Space used by the filesystem as a bar (<height>),(<width>) <fs>
fs_used_perc Space used by the filesystem as a percentage