Can someone explain to me why my weather script is not displayed in conky? The script seems to work just fine when I run it in terminal, but...
.conkyrc
PHP Code:
# UBUNTU-CONKY.
#
# Update interval in seconds
update_interval 1.0
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
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Minimum size of text area
#minimum_size 250 5
maximum_width 250
draw_shades no
draw_outline no # amplifies text if yes
draw_borders no
draw_graph_borders no
use_xft yes
xftalpha 0.9
xftfont Candera:size=7
uppercase no
override_utf8_locale yes
use_spacer no
stippled_borders 3
border_margin 9
border_width 10
# Gap between borders of screen and text
gap_x 10
gap_y 10
# Default colors and also border colors, grey90 == #e5e5e5
default_color grey
color0 97b9f4
color1 orange
color2 red
color3 green
# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
# stuff after 'TEXT' will be formatted on screen
TEXT
$color
${alignc}${offset -20}${color0}${font Arial:bold:size=12}${time %H:%M:%S}$font
${alignc}${time %A}, ${time %d %B %G}$color
${color1}$hr
${voffset -3}$alignc GMAIL
${voffset -9}$hr $color
${voffset -5}${color}You have ${color3}${texeci 100 python ~/scripts/gmail.py} ${color}new email(s).
${if_empty ${execi 100 python ~/scripts/gmail_subj.py}}${color1}$hr
${voffset -3}$alignc 3 DAY FORECAST
${voffset -9}$hr $color
${else}${execi 100 python ~/scripts/gmail_subj.py}
${color1}$hr
${voffset -3}$alignc 3 DAY FORECAST
${voffset -9}$hr $color${endif}
${voffset -10}${font weather:size=50}${alignc}${execi 60000 ~/scripts/weather.sh USVA0652 f 1p}${execi 60000 ~/scripts/weather.sh USVA0652 f 2p}${execi 60000 ~/scripts/weather.sh USVA0652 f 3p}${font}$color
${alignc}${offset -10}${execi 60000 ~/scripts/weather.sh USVA0652 f 1}${offset 10}${execi 60000 ~/scripts/weather.sh USVA0652 f 2}${offset 10}${execi 60000 ~/scripts/weather.sh USVA0652 f 3}
${color1}$hr
${voffset -3}$alignc SYSTEM
${voffset -9}$hr $color
${exec cat /etc/issue.net}
$sysname Kernel $kernel ($machine)
Uptime: $uptime
Battery status: $acpiacadapter, $battery
${color1}$hr
${voffset -3}$alignc PROCESSES
${voffset -9}$hr $color
${alignc}Processes: $processes Running: $running_processes
${color1}NAME${alignr}PID CPU% MEM%$color
${top name 1}${alignr}${offset -40}${top pid 1}${offset 15}${top cpu 1}${offset 15}${top mem 1}
${top name 2}${alignr}${offset -40}${top pid 2}${offset 15}${top cpu 2}${offset 15}${top mem 2}
${top name 3}${alignr}${offset -40}${top pid 3}${offset 15}${top cpu 3}${offset 15}${top mem 3}
${color1}$hr
${voffset -3}$alignc CPU/MEM
${voffset -9}$hr $color
${voffset -5}${cpugraph 50,250 000000 ff0000}
${voffset -55}${execi 1000 head /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //' | cut -b 0-20,31-48}
Clock: ${freq}MHz${alignr}Usage: ${cpu}% Temp: ${acpitemp}C
RAM: $memperc% ${membar 6}$color
Swap: $swapperc% ${swapbar 6}$color
${color1}$hr
${voffset -3}$alignc FILE SYSTEM
${voffset -9}$hr $color
Root: ${fs_free}/${fs_size /} ${fs_bar 6 /}
Home: ${fs_free /home}/${fs_size /home} ${fs_bar 6 /home}
${if_mounted /media/samba/}Samba: ${fs_free /media/samba}/${fs_size /media/samba} ${fs_bar 6 /media/samba}
${color1}$hr
${else}${color1}$hr $endif
${voffset -3}$alignc NETWORK
${voffset -9}$hr $color
${if_empty ${exec python ~/scripts/wifiUp.py}}${voffset -5}${downspeedgraph eth0 55,124 000000 ff0000} ${upspeedgraph eth0 55,124 000000 00ff00}$color
${voffset -60}${alignc}WIRED
Local IP: ${addr eth0} $alignr Public IP: ${execi 18000 ~/scripts/myip.sh}
Down: ${downspeed eth0} kb/s $alignr Up: ${upspeed eth0} kb/s
Total: ${totaldown eth0} $alignr Total: ${totalup eth0}
${else}${voffset -5}${downspeedgraph wlan0 64,124 000000 ff0000} ${upspeedgraph wlan0 64,124 000000 00ff00}$color
${voffset -69}${alignc}ESSID:"${wireless_essid wlan0}"
Local IP: ${addr wlan0} $alignr Public IP: ${execi 1800 ~/scripts/myip.sh}
Signal: ${execi 1800 ~/scripts/wifiQ.sh}% $alignr Bit Rate: ${execi 18000 ~/scripts/wifiBR.sh} Mb/s
Down: ${downspeed wlan0} kb/s $alignr Up: ${upspeed wlan0} kb/s
Total: ${totaldown wlan0} $alignr Total: ${totalup wlan0}$endif
weather.sh
PHP Code:
# This script was written by lvleph and inspired by the original conky weather script written by azhag (azhag@bsd.miki.eu.org)
#!/bin/bash
function cond_symb(){ #get condition symbol and print it
cnd=$(echo "$weather" | grep -A10 "class=\"titles\"" | head -n"$1" | tail -n1)
#translate condition to symbol in weather font
if echo "$cnd" | grep -E -i -q 'partly cloudy'; then
echo 'c'
elif echo "$cnd" | grep -E -i -q 'fair|sunny'; then
echo 'A'
elif echo "$cnd" | grep -E -i -q 'cloudy'; then
echo 'e'
elif echo "$cnd" | grep -E -i -q 'storm|thunder'; then
echo 'i'
elif echo "$cnd" | grep -E -i -q 'snow'; then
echo 'k'
elif echo "$cnd" | grep -E -i -q 'rain'; then
echo 'h'
elif echo "$cnd" | grep -E -i -q 'shower'; then
echo 'g'
fi
}
function temp(){ #get high and low temp and print it
#get high temp
hilo=$(echo "$weather" | grep -A6 "class=\"temps\"" | head -n"$1" | tail -n1)
tmp1=$(echo "$hilo" | cut -b19-22 | awk '{ sub(/&/,"\n"); print}' | awk '{ sub(" ",""); print}' | head -n1)
#get low temp
tmp2=$(echo "$hilo" | cut -b46-49 | awk '{ sub(/&/,"\n"); print}' | awk '{ sub(" ",""); print}' | head -n1)
echo "$tmp1°/$tmp2°" #print the high and low temp
}
code=$1 #zipcode or weather.com city code
system=$2 #f for imperial c for metric
#Check to see if server is available
if [ `ping -c1 216.109.126.70 | grep from | wc -l` -eq 0 ]; then
echo "Service not available"
exit
fi
weather=$(wget -O - http://weather.yahoo.com/forecast/"$code"_"$system".html)
case "$3" in
c) #give me current temp
tmp=$(echo "$weather" | grep -A1 "\"forecast\-temperature\"" | tail -n1 | cut -b5-8 | awk 'sub(/&d/,"")')
echo "$tmp°"
;;
[1-5]p) #give me the symbol for the current conditions
#get conditions
day=$(echo "$3" | awk 'sub(/p/,"")') #get day
head=$[2*$day+1] #translate day into number of lines
cond_symb $head #get condition symbol and print it
;;
[1-5]) #give me today's weather
#get high and low
head=$[$3+1] #translate day into number of lines
temp $head #get high and low temp and print it
;;
*) #didn't use correct option
echo "Usage error weather.sh <citycode> <system> <option>
weather.sh <citycode> <system> <option>
<citycode> - This can be either your zipcode or weather.com city code
<system> - c for metric or f for imperial
<option> - Only one option can be entered at a time
c displays current temp in chosen system
1p displays today's conditions in the chosen system
2p displays tomorrow's conditions in chosen system
3p displays 3rd day's conditions in chosen system
4p displays 4th day's conditions in chosen system
5p displays 4th day's conditions in chosen system
1 displays today's high/low temp in chosen system
2 displays tomorrow's high/low temp in chosen system
3 displays 3rd day's high/low temp in chosen system
4 displays 4th day's high/low temp in chosen system
5 displays 5th day's high/low temp in chosen system"
;;
esac
Bookmarks