Confi guration King of the Desktop

Turn your desktop into a dashboard that dis- plays system monitoring data, weather updates, news headlines, and more with Conky. BY DMITRI POPOV

When it comes to system monitoring tools, You should then see the Conky panel in all its color. In the example below, Conky renders a Conky [1] rules the roost supremely. This light- beauty at the bottom of the screen. transparent 300-pixel-wide window superim- weight utility can help you keep an eye on vir- posed on the desktop in the right corner of tually any aspect of your system, and it offers a Configuring Conky the screen: long list of options for you to tweak. But dis- By default, Conky’s configuration options are playing various information about your system stored in the .conkyrc file, which is split into maximum_width 300 is only one of Conky’s many talents: You can two parts: the first controls Conky’s appear- own_window_transparent yes use this nifty tool to pull headlines from RSS ance, and the second specifies which parame- own_window_type override feeds, check email, view the weather forecast, ters to monitor and how to display them. To alignment top_right and even execute commands and display out- learn the ropes, I’ll show you how to create a put right on your desktop. In other words, configuration file from scratch. So, fire up your By default, you can place the Conky window Conky lets you turn the desktop into a power- favorite text editor to get ready to go. at any of the four corners of the screen using ful dashboard that feeds you all the important To begin, you must specify the update inter- the alignment top_left, alignment top_right, information. val, or how often Conky “collects” the moni- alignment bottom_left, and alignment bottom_ Configuring Conky can be a daunting prop- tored data. This is done by specifying the up- right options. But what if you want to move the osition, but despair not: I’ll demonstrate how date_interval option in seconds, for example window slightly to the left or a little bit down? to tweak Conky’s settings and put this powerful update_interval 1.0 or update_interval 5.0. You To do this, you can use the gap_x and gap_y tool to some clever uses. must also set the total_run_times option to 0 to options, which specify the distance between let Conky run until you close it. the borders of the screen and the window: Install Conky By default, Conky uses a monospace font, Because Conky is available in software but you can instruct it to use any font installed gap_x 10 repositories, installing it is a matter of running on your system by enabling the use_xft option gap_y 35 the sudo apt-get install conky command. Be- and specifying a font in the xftfont setting. For sides the core package, you might want to in- example, if you want Conky to use Droid Sans If you don’t want text in the Conky window to stall a few third-party additions that extend Mono 9pt font, these options should be: appear in caps, use the uppercase no option. Conky’s functionality. Conky offers many more configuration options To do this, you have to add the conkyhard- use_xft yes for you to tweak, but these will get you started. core personal package archive (PPA) using the xftfont Droid Sans Mono:size=9 With the basic display options in place, you following command: override_utf8_locale yes can start adding and configuring the system parameters you want Conky to monitor. This is sudo apt-add-repository U The last parameter forces Conky to use UTF8 done using so-called variables. For example, to ppa:conkyhardcore/ppa && U encoding when use_xft yes is enabled. display the kernel version of your system, you sudo apt-get update Quite often, the Conky window might flicker can use the kernel variable. Note that each during refreshing, which can be very annoying. variable is preceded by the $ sign. Conky also Conky has two options to help you to combat includes a few variables that allow you to con- Getting a Taste of Conky that problem. The double_buffer option lets trol the appearance of the output. The color Before you get your hands dirty tweaking Con- Conky use the X double-buffer extension that variable allows you to specify text color, ky’s configuration file, you might want to get a can eliminate flickering. If enabling double_ whereas the alignr variable allows you to right- taste of Conky’s capabilities using one of many buffer doesn’t help, you can use the own_win- justify text. To see how this works in practice, ready-to-use solutions like Conky Ubuntu dow option that forces Conky to run in a sepa- take a look at the following example: Lucid Theme (Figure 1) [2]. Grab the latest ver- rate window. To be on the safe side, you might sion of the theme, unpack the downloaded ar- want to enable both options: ${color lightgrey}Uptime:$color U chive and move the resulting .conkytheme $uptime $alignr${color lightgrey}U folder to your home directory. double_buffer yes Load:$color $loadavg Launch the terminal and run the following own_window yes command: The ${color lightgrey} variable sets the text to The next step is to specify the window settings, light gray. To switch to the default color (white), conky - ~/.conkytheme/conkyrc including its width, alignment, and default use the color variable without a parameter.

86 ISSUE 06 DISCOVERY GUIDE Confi guration

Conky sports several graphing variables that If you want to keep an eye on the download use Conky to go out and get the very latest you can use to visualize monitored data. The and upload speed, you can use the headlines from your favorite RSS feed: cpugraph variable, for example, displays CPU downspeedf and upspeedf variables (or usage as a graph. When used without any pa- downspeed and upspeed variables if you don’t ${rss http://www.linux-magazine.com/U rameters, the graph is shown using the default want to display the trailing decimal): rss/feed/productivity_sauce 10 U solid color, but you can use Hex color values item_titles 5} to specify gradients, which make the graph ${color lightgrey}Download speed: U look much better: $color${downspeedf wlan0} Kb/sec In the example above, Conky fetches the five most recent headlines from the Productivity ${cpugraph 000000 ffffff} Alternatively, you can use the downspeed- Sauce blog’s RSS feed every 10 minutes. Be- graph and upspeedgraph variables to display cause Identi.ca and Twitter publish updates via To display the memory-related data, you can the download and upload speeds as graphs. RSS, you can use the rss variable to keep an use the memmax (the total amount of RAM), And if you want to monitor the total amount of eye on updates from people you follow: mem (memory in use), and memperc (percent- downloaded and uploaded data, you can use age of memory in use) variables: the totaldown and totalup variables: ${rss http://identi.ca/api/statuses/U friends_timeline/dmpop.rss U ${color lightgrey}RAM usage:$color U ${color red}Down: U 15 item_titles 7} $mem/$memmax - $memperc% $color${totaldown wlan0} U $alignr ${color green}Up: U Perhaps the most versatile variable in Conky’s When it comes to monitoring disk usage, you $color${totalup wlan0} arsenal is execi. It allows you to run any shell have a few variables from which to choose, in- command and display the output in the Conky cluding fs_free (free space), fs_size (total size), This can come in particularly handy if you are window. You can put this functionality to many and fs_bar (space used bar): using a connection with a download cap. nifty uses. For example, you can create a plain- text file for your to-do list and then use the fol- ${color grey}Disk usage: U Clever Tricks lowing command to display it in the Conky $color${fs_free /} of U Conky includes several conditional variables window: ${fs_size /} that give you even more flexibility. For exam- ${fs_bar 6 /} ple, if your machine has a wired and wireless ${execi 30 cat ~/TODO.txt | fold -w40} interface, you might want to monitor both of Conky also includes several variables that them. But usually you use only one interface at The execi variable can do more advanced allow you to monitor wireless interfaces, in- a time, so you don’t need Conky to display in- tricks too, like displaying the number of in- cluding wireless_essid (returns the ESSID name formation about the inactive interface. This is coming email messages in your inbox. For that, of the access point), wireless_link_qual (returns where the if_existing, else, and endif variables you can use the conkyemail package from the wireless link quality), and wireless_link_bar come into the picture. Using them, you can conkyhardcore repository you installed earlier. (returns the wireless link quality displayed as a specify a condition that displays information Just install the package with sudo apt-get install bar). about a specific interface only when it’s active; conkyemail. Then, issue the conkyEmail --help To obtain the name of the wireless interface otherwise, the condition either hides the un- command to view a list of all available options. you will want to monitor with these variables, necessary data or displays a message like “No You can use these options to create an appro- use the ifconfig command, which returns a list Network Connection”: priate execi command. If you use Gmail, you of available network interfaces. Then, you can can use the command below to poll your use the variables to display the desired infor- ${if_existing /proc/net/route eth0}U Gmail account (replace the USER and PASS- mation about a specific wireless interface as ${color #ffcb48}Ethernet ${hr 1} WORD values with your actual Gmail user follows:: ${color lightgrey}IP address: U name and password): $alignr$color${addr eth0}${else}U U ${color #ffcb48}Wi-Fi ${hr 1} No Network Connection${endif} ${color #ffcb48}${ ${color lightgrey}ESSID: U execi 30 conkyEmail U $color${wireless_essid wlan0} Besides the system-related variables, Conky --servertype=IMAP U ${color lightgrey}Wireless signal: U has several other variables that can be used to --servername=imap.gmail.com U $color${wireless_link_qual wlan0}% pull and to process data from other sources. --port=993 --ssl --username=USER U ${wireless_link_bar wlan0} For example, using the rss variable, you can --password=PASSWORD} new emails

Figure 1: Conky Lucid Theme in all its beauty. Figure 2: Here is what Conky looks like on my notebook.

DISCOVERY GUIDE ISSUE 06 87 Confi guration

The conkyhardcore repository also contains a http://xoap.weather.com/search/U Conky, each using its own configuration file. package called conkyforecast, which can pull search?where=NEW YORK You can configure the .conkyrc file to place weather forecasts and present them on your one Conky window in the top right corner of desktop. Configuring conkyforecast requires Make a note of the returned value (in this case, the screen and a .conkyrc2 file to display an- some work, but the results are worth it. it is USNY0996). Instead of manually configur- other window in the top left corner. Then, you To start, install the conkyforecast package: ing the presentation layout, you can use the can use the following command to launch two sample template. To copy the template to your Conky instances: sudo apt-get install conkyforecast home directory, use the following command: (conky &);(conky -c .conkyrc2 &) To pull weather data, you have to obtain a Part- cp /usr/share/conkyforecast/example/U ner ID and License Key from The Weather conkyForecast.template U Channel service [3] and follow the instructions ~/conkyForecast.template Final Word for an account. Then, copy the config file into To wrap up, you can see the .conkyrc file that I your home directory, Then, add this command to the .conkyrc file as use in Listing 1 [4]. Feel free to use this exam- follows: ple as a starting point for creating your own cp /usr/share/conkyforecast/U Conky configuration. ■ conkyForecast.config U ${execpi 1800 conkyForecast U ~/.conkyForecast.config --location= USNY0996 U --template=~/conkyForecast.template} Info open the copied file in your text editor, and [1] Conky: http://conky. sourceforge. net enter the Partner ID and License Key: Now when you launch Conky, you should be able to see the weather forecast in all its beauty [2] Conky Ubuntu Lucid Theme: http:// bit. ly/ bJvQrT XOAP_PARTNER_ID = Your Partner ID (Figure 2). XOAP_LICENCE_KEY = Your License Key Although Conky lets you display all kinds of [3] Weather data feed: http:// www. useful information, your screen’s height limits weather. com/ services/ xmloap. html Next, you have to find the Location ID of your how much data you can show on your desk- [4] Code for this article: http://www. city. To do this, query Weather.com for the city top. But there is a workaround to this problem: ubuntu-user.com/Online/Article-Code code using the name of the city – for example: You can launch two separate instances of

Listing 1: .conkyrc Sample 02 30

03 update_interval 1.0 31 ${color grey}Disk usage

04 double_buffer yes 32 /root $color${fs_bar 6 /} 05 background no 33 ${color grey}Free: $color${fs_free /} 06 ${color grey}Total: $color${fs_size /} 07 use_xft yes 34 08 xftfont Droid Sans Mono:size=9 35 ${if_existing /proc/net/route wlan0} 09 override_utf8_locale yes ${color #ffcb48}Wireless ${hr 1} 10 text_buffer_size 2048 36 ${color lightgrey}Wireless signal: 11 $color${wireless_link_qual wlan0}% 12 maximum_width 300 37 ${color lightgrey}IP address: $color${addr wlan0} 13 own_window yes 38 ${color lightgrey}Download speed: 14 own_window_transparent yes $color${downspeedf wlan0} Kb/sec 15 own_window_type override 39 ${downspeedgraph wlan0} 16 alignment top_right 40 ${color red}Downloaded: $color${totaldown wlan0} $alignr 17 ${color green}Uploaded: $color${totalup wlan0} 18 gap_x 10 ${else}No Wireless Network${endif} 19 gap_y 35 41 20 42 ${if_existing /proc/net/route eth0} 21 TEXT ${color #ffcb48}Ethernet ${hr 1} 22 $font $color$sysname $kernel ${color lightgrey}Uptime: 43 ${color lightgrey}IP address: $color${addr eth0} $color $uptime 44 ${color lightgrey}Download speed: 23 $color${downspeedf eth0} Kb/sec 24 ${color lightgrey}CPU: $color${freq}Mhz ${color lightgrey}Temp:$color $acpitemp°C 45 ${downspeedgraph eth0}

25 $color${cpugraph} 46 ${color red}Downloaded: $color${totaldown eth0} $alignr

26 ${color green}Uploaded: $color${totalup eth0} ${else}No Wired Network${endif} 27 ${color lightgrey}RAM usage $color($memperc%):

28 ${membar} 47

29 ${color lightgrey}Used: $color$mem 48 ${ execpi 1800 conkyForecast --location=DAXX0003 ${color lightgrey}Total: $color$memmax --template=~/conkyForecast.template}

88 ISSUE 06 DISCOVERY GUIDE