Skip to main content

Installing conky with weather forecast in Ubuntu 10.10

November 29, 2010 by wgarcia

(UPDATE on November 26, 2011: the weather.com site has changed and  I have updated my scripts so that they still work)

Conky is a free, light-weight system monitor for X, that displays any information on your desktop. Yesterday, after a question I got in an Ubuntu forum, I decided to install it in my Ubuntu 10.10 desktop and laptop computer. It was not easy and I had to go to different forums posts and links, so I decided to write this post on what I did.

My conky setup involves two different sections and occupies quite a bit of the desktop. In the the two monitor setup of my desktop this is not a problem, but in the laptop it has the problem that Conky, despite sitting always below any windows, sits over desktop iconcs, so any icon that you have in the desktop area where conky sits will be hidden by it. I don't use desktop icons too much and the icons can still be accessed by hovering over the conky window with the mouse, but be aware of this if you want to install it.

In my desktop computer I'm using two monitors and I have configured Conky to show in the upper right corner, and it shows in the second screen. In the laptop it's also defined to show up in the upper right corner. I also installed conkyForecast which is a python script to access weather information for conky fed from www.weather.com, an online weather service.

This is how nice it looks in the laptop, with the "comet" background that can be found in /usr/share/backgrounds/cosmos/comet.jpg:

Desktop

The first thing to do is to install conky itself:

sudo apt-get install conky

We will wait to configure conky until we have installed everything for the weather forecast.

You need information on your location. For this browse to the www.weather.com site, and on the upper left part you will find a text field to enter a location and ask for the weather there. Enter your location, for instance I entered Barcelona, and look the URL of this in your browser, I for instance see:

http://www.weather.com/weather/today/Barcelona+Spain+SPXX0015

You need the code after the last "+" sign, that is SPXX0015.

Before going on you need to download a couple of fonts, at least for my setup, one for the Ubuntu logo and title, and the other one for the weather symbols (sun, clouds, and so on).

The ubuntu symbols can be downloaded from: 

http://www.gnome-look.org/content/show.php/OpenLogos?content=54390

You can place the downloaded file either in a folder called ".fonts" in your home directory or in /usr/share/fonts/truetype/myfonts.

The weather font you can download from:

http://www.dafont.com/search.php?psize=m&q=weather

Install the ttf file (rename it to weather.ttf) in any of the two places above.

Next you have to install the  conkyForecast python script. This is in a PPA, you can install it with the following two lines in a terminal:

sudo add-apt-repository ppa:conkyhardcore/ppa
 
sudo apt-get update 
 
sudo apt-get install conkyforecast

Now copy the conkyForecast to your home directory:

cp /usr/share/conkyforecast/conkyForecast.config ~/.conkyForecast.config

Well, everything has been installed now. We now have to edit the configuration file for conky and for conkyforecast. We first have to edit the file ".conkyForecast.config" that we put the home directory:

# config settings for conkyForecast.py
CACHE_FOLDERPATH = /tmp/
CONNECTION_TIMEOUT = 5
EXPIRY_MINUTES = 30
TIME_FORMAT = %H:%M
DATE_FORMAT = %Y-%m-%d
LOCALE = us_US
MAXIMUM_DAYS_FORECAST = 4
AUTO_NIGHT = False
BASE_XOAP_URL = http://xml.weather.com/weather/local/<LOCATION>?cc=*&dayf=10&link=xoap&prod=xoap&key=<XOAP_LICENCE_KEY>&unit=m
PROXY_HOST = 
PROXY_PORT = 8080
PROXY_USERNAME = 
PROXY_PASSWORD = 

Next you have to create two files in your home directory, ".conkyrc1" and ".conkyrc2" to configure each one of the conky panels that can be seen in my desktop. Here they are, take care of also entering your location in the appropriate places instead of mine. In ".conkyrc1" adjust also the parameters for processors and disk to your environment:

.conkyrc1:

 

#############################
##  VinDSL | 1280x1024x24  ##
#############################
 
####
## Use XFT? Required to Force UTF8 (see below).
#
use_xft yes
xftfont LiberationSans:size=9
xftalpha 0.1
text_buffer_size 2048
 
####
## Force UTF8? Requires XFT (see above).
## Displays degree symbol, instead of °, etc.
#
override_utf8_locale yes
 
####
## Update interval in seconds.
#
update_interval 1.5
 
####
## This is the number of times Conky will update before quitting.
## Set to zero to run forever.
#
total_run_times 0
 
####
## Create own window instead of using desktop (required in nautilus)?
#
own_window yes
own_window_type override
own_window_transparent yes
 
####
## Use double buffering? Reduces flicker.
#
double_buffer yes
 
####
## Draw shades?
#
draw_shades no
 
####
## Draw outlines?
#
draw_outline no
 
####
## Draw borders around text?
#
draw_borders no
 
####
## Draw borders around graphs?
#
draw_graph_borders no
 
####
## Print text to stdout?
## Print text in console?
#
out_to_ncurses no
out_to_console no
 
####
## Text alignment.
#
alignment top_right
 
 
####
## Minimum size of text area.
#
minimum_size 235 0
 
####
## Specify width and height for bars.
#
default_bar_size 0 4
 
####
## Gap between text and screen borders.
#
gap_x 400
gap_y 28
 
####
## Shorten MiB/GiB to M/G in stats.
#
short_units yes
 
####
## Pad % symbol spacing after numbers.
#
pad_percents 0
 
####
## Limit the length of names in "Top Processes".
#
top_name_width 10
 
####
## Subtract file system -/+buffers/cache from used memory?
## Set to yes, to produce meaningful physical memory stats.
#
no_buffers yes
 
####
## Set to yes, if you want all text to be in UPPERCASE.
#
uppercase no
 
####
## Number of cpu samples to average.
## Set to 1 to disable averaging.
#
cpu_avg_samples 4
 
####
## Number of net samples to average.
## Set to 1 to disable averaging.
#
net_avg_samples 2
 
####
## Add spaces to keep things from moving around?
## Only affects certain objects.
#
use_spacer right
 
####
## My colors.
#
color0 White
color1 Ivory
color2 Ivory2
color3 Ivory3
color4 Tan1
color5 Tan2
color6 Gray
color7 AntiqueWhite4
color8 DarkSlateGray
color9 Black
 
TEXT
 
##################
##     LOGO     ##
##################
${voffset -42}${font OpenLogos:size=103}${color2}v${voffset -66}${goto 178}${font UbuntuTitleBold:size=20}${color4}10.10
##################
##    SYSTEM    ##
##################
${voffset 10}${font Arial:bold:size=9.5}${color4}SYSTEM ${color8} ${hr 2}
${voffset 4}${font OpenLogos:size=10}${color2}u${voffset -4}${font}${color6} ${sysname} ${kernel} ${alignr} ${machine}
${voffset 2}${font StyleBats:size=10}${color2}A${voffset -1}${font}${color6} Intel I5 ${alignr}${freq_g cpu0} GHz
${voffset 2}${font StyleBats:size=10}${color2}q${voffset -1}${font}${color6} Uptime ${alignr}${uptime}
${voffset 2}${font StyleBats:size=10}${color2}o${voffset -1}${font}${color6} File System ${alignr}${fs_type}
##################
##  PROCESSORS  ##
##################
${voffset 5}${font Arial:bold:size=9.5}${color4}PROCESSORS ${color8}${hr 2}
${voffset 2}${font StyleBats:size=10}${color2}k${voffset -2}${font}${color6} CPU1  ${cpu cpu1}%${color7}${alignc 35}${cpubar cpu1}
${voffset 2}${font StyleBats:size=10}${color2}k${voffset -2}${font}${color6} CPU2  ${cpu cpu2}%${color7}${alignc 35}${cpubar cpu2}
${voffset 2}${font StyleBats:size=10}${color2}k${voffset -2}${font}${color6} CPU3  ${cpu cpu3}%${color7}${alignc 35}${cpubar cpu3}
${voffset 2}${font StyleBats:size=10}${color2}k${voffset -2}${font}${color6} CPU4  ${cpu cpu4}%${color7}${alignc 35}${cpubar cpu4}
##################
##    MEMORY    ##
##################
${voffset 5}${font Arial:bold:size=9.5}${color4}MEMORY ${color8}${hr 2}
${voffset 2}${font StyleBats:size=10}${color2}l${voffset -2}${font}${color6} RAM ${goto 95}${mem}/ ${memmax}${alignr}${memperc}%
${color7}${membar}
##################
##     HDD      ##
##################
${voffset 2}${font Arial:bold:size=9.5}${color4}HDD ${color8}${hr 2}
${voffset 2}${font StyleBats:size=10}${color2}x${voffset -2}${font}${color6} ROOT ${goto 95}${fs_used /} / ${fs_size /}${alignr}${fs_free_perc /}%
${color7}${fs_bar /}
${voffset 1}${font StyleBats:size=10}${color2}x${voffset -2}${font}${color6} HOME ${goto 95}${fs_used /home}/ ${fs_size /home}${alignr}${fs_free_perc /home}%
${color7}${fs_bar /home}
${voffset 1}${font StyleBats:size=10}${color2}x${voffset -2}${font}${color6} Data ${goto 95}${fs_used /data}/ ${fs_size /data}${alignr}${fs_free_perc /data}%
${color7}${fs_bar /data}
${voffset 1}${font StyleBats:size=10}${color2}4${voffset -2}${font}${color6} SWAP ${goto 95}${swap} / ${swapmax}${alignr}${swapperc}%
${color7}${swapbar}
##################
# TOP PROCESSES ##
##################
${voffset 3}${font Arial:bold:size=9.5}${color4}TOP PROCESSES ${color8}${hr 2}
${voffset 2}${font StyleBats:size=10}${color1}h${voffset -3}${font}${color6} ${top_mem name 1}${goto 115}${top_mem mem_res 1}${alignr}${top_mem mem 1}%
${voffset 2}${font StyleBats:size=10}${color1}h${voffset -3}${font}${color6} ${top_mem name 2}${goto 115}${top_mem mem_res 2}${alignr}${top_mem mem 2}%
${voffset 2}${font StyleBats:size=10}${color1}h${voffset -3}${font}${color6} ${top_mem name 3}${goto 115}${top_mem mem_res 3}${alignr}${top_mem mem 3}%
${voffset 2}${font StyleBats:size=10}${color1}h${voffset -3}${font}${color6} ${top_mem name 4}${goto 115}${top_mem mem_res 4}${alignr}${top_mem mem 4}%
##################
##   NETWORK    ##
##################
${voffset 5}${font Arial:bold:size=9.5}${color4}NETWORK ${color8}${hr 2}
${voffset 2}${font PizzaDude Bullets:size=10}${color2}a${font}${color6} Private IP${alignr}${addr eth0}
${font PizzaDude Bullets:size=10}${color2}a${font}${color6} Public  IP${alignr}${execi 600 wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]\|.]//g'}
${voffset 4}${font PizzaDude Bullets:size=10}${color2}T${font}${color6} Down${alignr}${downspeed eth0}
${font PizzaDude Bullets:size=10}${color2}N${font}${color6} Up${alignr}${upspeed eth0}
${voffset 4}${font PizzaDude Bullets:size=10}${color2}T${font}${color6} Downloaded${alignr}${totaldown eth0}
${font PizzaDude Bullets:size=10}${color2}N${font}${color6} Uploaded${alignr}${totalup eth0}

.conkyrc2:

 

#############################
##  VinDSL | 1280x1024x24  ##
#############################
 
####
## Use XFT? Required to Force UTF8 (see below).
#
use_xft yes
xftfont LiberationSans:size=9
xftalpha 0.1
text_buffer_size 2048
 
####
## Force UTF8? Requires XFT (see above).
## Displays degree symbol, instead of °, etc.
#
override_utf8_locale yes
 
####
## Update interval in seconds.
#
update_interval 1.5
 
####
## This is the number of times Conky will update before quitting.
## Set to zero to run forever.
#
total_run_times 0
 
####
## Create own window instead of using desktop (required in nautilus)?
#
own_window yes
own_window_type override
own_window_transparent yes
 
####
## Use double buffering? Reduces flicker.
#
double_buffer yes
 
####
## Draw shades?
#
draw_shades no
 
####
## Draw outlines?
#
draw_outline no
 
####
## Draw borders around text?
#
draw_borders no
 
####
## Draw borders around graphs?
#
draw_graph_borders no
 
####
## Print text to stdout?
## Print text in console?
#
out_to_ncurses no
out_to_console no
 
####
## Text alignment.
#
alignment top_right
 
####
## Minimum size of text area.
#
minimum_size 235 0
 
####
## Specify width and height for bars.
#
default_bar_size 0 4
 
####
## Gap between text and screen borders.
#
gap_x 10
gap_y 28
 
####
## Shorten MiB/GiB to M/G in stats.
#
short_units yes
 
####
## Pad % symbol spacing after numbers.
#
pad_percents 0
 
####
## Limit the length of names in "Top Processes".
#
top_name_width 10
 
####
## Subtract file system -/+buffers/cache from used memory?
## Set to yes, to produce meaningful physical memory stats.
#
no_buffers yes
 
####
## Set to yes, if you want all text to be in UPPERCASE.
#
uppercase no
 
####
## Number of cpu samples to average.
## Set to 1 to disable averaging.
#
cpu_avg_samples 4
 
####
## Number of net samples to average.
## Set to 1 to disable averaging.
#
net_avg_samples 2
 
####
## Add spaces to keep things from moving around?
## Only affects certain objects.
#
use_spacer right
 
####
## My colors.
#
color0 White
color1 Ivory
color2 Ivory2
color3 Ivory3
color4 Tan1
color5 Tan2
color6 Gray
color7 AntiqueWhite4
color8 DarkSlateGray
color9 Black
 
TEXT
 
##################
##   WEATHER    ##
##################
${voffset 5}${font Arial:bold:size=9.5}${color4}WEATHER ${color8}${hr 2}
# ${goto 59}${font Weather:size=40}${color1}y${voffset -8}${font RadioSpace:size=32}${color3}${offset 14}${execpi 600 conkyForecast --location=SPXX0015}
${goto 59}${font Weather:size=40}${color1}y${voffset -8}${font RadioSpace:size=32}${color3}${offset 14}${execpi 600 conkyForecast --location=GMXX2809}
${voffset -17}${font Arial:size=22}${color4}${alignc}${execi 600 conkyForecast --location=SPXX0015 --datatype=OB}
${voffset 7}${goto 20}${font ConkyWindNESW:style=Bold:size=38}${color2}${execi 600 conkyForecast --location=SPXX0015 --datatype=BS}${goto 96}${voffset -5}${font ConkyWeather:style=Bold:size=40}${color2}${execi 600 conkyForecast --location=SPXX0015 --datatype=WF}${voffset -2}${goto 180}${font MoonPhases:size=30}${color2}${execi 600 conkyForecast --location=SPXX0015 --datatype=HT}
${voffset -20}${goto 30}${font}${color2}${execi 600 conkyForecast --location=SPXX0015 --datatype=WS}${goto 86}Feels like ${execi 600 conkyForecast --location=SPXX0015 --datatype=LT --centeredwidth=4 }${goto 182}Lunar
${voffset 10}${goto 30}${font}${color2}${execi 600 conkyForecast --location=SPXX0015 --datatype=DW --startday=1 --shortweekday}${goto 83}${execi 600 conkyForecast --location=SPXX0015 --datatype=DW --startday=2 --shortweekday}${goto 136}${execi 600 conkyForecast --location=SPXX0015 --datatype=DW --startday=3 --shortweekday}${goto 192}${execi 600 conkyForecast --location=SPXX0015 --datatype=DW --startday=4 --shortweekday}
${goto 20}${font}${color2}${font ConkyWeather:size=32}${execi 600 conkyForecast --location=SPXX0015 --datatype=WF --startday=1 --endday=4 --spaces=1}
${goto 22}${voffset -30}${font}${color2}${execi 600 conkyForecast --location=SPXX0015 --datatype=HT --startday=1 --hideunits --centeredwidth=4 }/${execi 600 conkyForecast --location=SPXX0015 --datatype=LT --startday=1 --hideunits --centeredwidth=4 }${goto 76}${execi 600 conkyForecast --location=SPXX0015 --datatype=HT --startday=2 --hideunits --centeredwidth=4 }/${execi 600 conkyForecast --location=SPXX0015 --datatype=LT --startday=2 --hideunits --centeredwidth=4 }${goto 130}${execi 600 conkyForecast --location=SPXX0015 --datatype=HT --startday=3 --hideunits --centeredwidth=4 }/${execi 600 conkyForecast --location=SPXX0015 --datatype=LT --startday=3 --hideunits --centeredwidth=4 }${goto 185}${execi 600 conkyForecast --location=SPXX0015 --datatype=HT --startday=4 --hideunits --centeredwidth=4 }/${execi 600 conkyForecast --location=SPXX0015 --datatype=LT --startday=4 --hideunits --centeredwidth=4 }
 
 
################## 
##     TIME     ##
##################
${voffset 5}${font Arial:bold:size=9.5}${color4}TIME ${color8}${hr 2}
${voffset -4}${if_match ${time %l}<=9}${font RadioSpace:size=32}${color3}${alignc 2}${time %H:%Mh }${else}${if_match ${time %l}>=10}${font RadioSpace:size=32}${color3}${alignc 2}${time %H:%Mh}${endif}${endif}
${voffset -35}${font LiberationSans:size=8}${color4}${alignc 5}Sunrise${offset 1}${execi 600 conkyForecast --location=SPXX0015 --datatype=SR --startday=1}${color3}${offset 2}|${offset 2}${color4}Sunset${offset 1}${execi 600 conkyForecast --location=SPXX0015 --datatype=SS --startday=1}
##################
##   CALENDAR   ##
##################
${voffset 5}${font Arial:bold:size=9.5}${color4}DATE ${color8}${hr 2}
${voffset 2}${font LiberationMono:size=11}${color3}${alignc 5}${execpi 60 DJS=`date +%_d`; ncal -M -C -h| sed s/"\(^\|[^0-9]\)$DJS"'\b'/'\1${color orange}'"$DJS"'$color'/}

You can try the configuration to see if everything is OK by giving the following commands from a terminal:

conky -c ~/.conkyrc1 &

conky -C ~/.conkyrc2 &

Now finally you have to configure these two commands as startup programs so that you get conky in your desktop every time you start your desktop. For this you have to create another script to autostart conky when you start your desktop session. This is the script. that you have to locate in your home directory and call for instance .conky_autostart.sh: 

#!/bin/bash
sleep 20 && conky -c ~/.conkyrc1
sleep 20 && conky -c ~/.conkyrc2

And now you have to go to the menu Preferences -> Startup programs, and add this script as it is shown in the following screenshot:

Startup Conky

A final comment on the problem that I mentioned at the beginning on hidden icons. If a desktop icon is placed in the area where you have the conky output, it will be hidden by it sitting between the desktop and conky and you will not be able to see it. This does not happen with desktop windows which always sit in front of conky. This is not a big problem for me since I keep my desktop quite clean of icons, but if I plug in a USB for instance, the shortcut may come in the conky area and be hidden. This is not a problem either, if you don't find an icon just hover with your mouse over the conky area and the pointer will change to a pointing finger when it is over the icon. Just press the left button of the mouse and keeping it pressed move to another area of the desktop free of conky. This will move the hidden icon out of the conky area.

Premium Drupal Themes by Adaptivethemes