Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Conky Weather Script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
FrankRizz0
l33t
l33t


Joined: 29 Nov 2006
Posts: 617

PostPosted: Sat Apr 29, 2017 1:29 pm    Post subject: Conky Weather Script Reply with quote

Good Morning All;

Not sure if I should be asking this here, but I have searched and searched and posted and posted without any help (I'm desperate so I am trying here). I'm trying to get weather working in my conky script, and I can't seem to get it working, it does not want to display the temperature. Below is what I have for my weather:

Code:
${color 000000}${font Xirod:size=10}${execi 600  sed -n '2p' ~/.accuweather/curr_cond}${goto 45}${voffset -10}Currently: ${execpi 600 sed -n '4p' $HOME/accuweather_conky/curr_cond}°C
${goto 45}${execpi 600 sed -n '3p' $HOME/accuweather_conky/curr_cond|fold -w30}


Thanks in advance for any assistance.
Back to top
View user's profile Send private message
comprookie2000
Retired Dev
Retired Dev


Joined: 25 Jul 2004
Posts: 925
Location: Sun City Center, Florida

PostPosted: Sun Apr 30, 2017 12:01 am    Post subject: Reply with quote

Here is what I use;
Code:

${color Gray}Current Conditions$color
${execi 600 /home/david/conky/scripts/wundergroumd.py}


wunderground.py
Code:

#!/usr/bin/python2
#
# Fetches Weather info from Weather Underground
#
# Usage: ./wundergound.py zipcode
#
# International:
#  * Go to http://www.wunderground.com/
#  * Find your city
#  * Click the RSS icon
#  * Station ID is the number that follows /stations/ in the url
#
#
 
# Values are either True or False
metric=False
international=False
 
import sys
import feedparser
 
url="http://rss.wunderground.com/auto/rss_full/FL/Tampa.xml"
 
feed=feedparser.parse(url)

 
if not feed.feed:
    # Assume Error
    print("Error")
    sys.exit(1)
 
current=feed['items'][0].title
 
if metric:
    temp=current.split(",")[0].split(":")[1].split("/")[1].strip()
else:
    temp=current.split(",")[0].split(":")[1].split("/")[0].strip()
 
condition=current.split(",")[1].split("-")[0].strip()
 
print('%s - %s' % (temp, condition))

_________________
http://dev.gentoo.org/~dabbott/
Back to top
View user's profile Send private message
FrankRizz0
l33t
l33t


Joined: 29 Nov 2006
Posts: 617

PostPosted: Sun Apr 30, 2017 1:36 pm    Post subject: Reply with quote

OK so tried your conky and I could not getting it working, but thank you for giving me an alternative. Here is my entire conky, and the script I am using

Conky
Code:

#==============================================================================
#                                  conkyrc
#
#  display : horizontal ring gauge
#
#  author  : SLK
#  version : v20121005-01
#  license : Distributed under the terms of GNU GPL version 2 or later
#
#==============================================================================

background no
update_interval 1

cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius

double_buffer yes
no_buffers yes
text_buffer_size 2048

gap_x 40
gap_y 50
minimum_size 500 200
maximum_width 800
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment tr

draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

override_utf8_locale yes
use_xft yes
xftfont caviar dreams:size=9
xftalpha 0.5
uppercase no

default_color 000000
color1 000000
color2 000000
color3 000000

lua_load ~/.conky123/conky_grey.lua
lua_draw_hook_post main

TEXT
${voffset 35}${font Ubuntu:size=10}${color1}
${offset 20}CPU${offset 60}RAM${offset 50}ROOT${offset 50}MEDIA${offset 50}UP${offset 50}DOWN

${font Xirod:size=7}${voffset 0}${offset -1}${font Xirod:size=7}${voffset 10}${color1}Gentoo Linux-2.3
${font Xirod:size=7}${voffset 0}${offset -2}${font Xirod:size=7}${voffset 2}${color1}$sysname $kernel
${font Xirod:size=7}${voffset 0}${offset -2}${font Xirod:size=7}${voffset 2}${color1}${cpu}% ${freq_g} Ghz ${machine}  ${acpitemp}°C
${font Xirod:size=7}${voffset 0}${offset -2}${font Xirod:size=7}${voffset 2}${color1}${execi 1000 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //'| uniq | cut -c 1-26}
${font Xirod:size=7}${voffset -12}${offset 93}${font Xirod:size=7}${voffset -34}${color1}${mem}/${memmax}
${font Xirod:size=7}${voffset 0}${offset 170}${font Xirod:size=7}${voffset -9}${color1}${fs_used /}/${fs_size /}
${font Xirod:size=7}${voffset 0}${offset 200}${font Xirod:size=7}${voffset 5}${color1}${diskiograph 6,50 FF6600 FF6600} 
${font Xirod:size=7}${voffset 0}${offset 220}${font Xirod:size=7}${voffset 3}${color1}${diskio}/s
${font Xirod:size=7}${voffset 0}${offset 250}${font Xirod:size=7}${voffset -38}${color1}${fs_used /home/bry2k200/Media}/${fs_size /home/bry2k200/Media}
${font Xirod:size=7}${voffset 0}${offset 327}${font Xirod:size=7}${voffset -10}${color1}${totalup enp68s0}/${upspeed enp68s0}
${font Xirod:size=7}${voffset 0}${offset 406}${font Xirod:size=7}${voffset -10}${color1}${totaldown wlo1}/${downspeed wlo1}
${font Xirod:size=7}${voffset 0}${offset 350}${font Xirod:size=7}${voffset 5}${color1}LAN ${addr enp68s0}
${font Xirod:size=7}${voffset 0}${offset 350}${font Xirod:size=7}${voffset 0}${color1}WAN ${addr wlo1}
${font Xirod:size=7}${voffset 0}${offset 350}${font Xirod:size=7}${voffset 0}${color1}MAN 204.112.153.244
${font Xirod:size=7}${voffset 0}${offset 350}${font Xirod:size=7}${voffset 0}${color1}GATE ${gw_ip}
${font Xirod:size=7}${voffset 0}${offset 350}${font Xirod:size=7}${voffset 0}${color1}${wireless_essid wlo1} ${wireless_mode wl01}
${font Xirod:size=8}${goto 160}${voffset -20}${time %A} ${time %d %B %Y}
${font Xirod:size=18}${goto 169}${voffset -3}${time %H}:${time %M}
${font Xirod:size=8}${goto 60}${voffset -5}User: ${uid_name 1000}@${nodename} for ${uptime_short}  Updates:${execi 360 aptitude search "~U" | wc -l | tail}    Load $loadavg
${font Xirod:size=8}${goto -12}${voffset 10}${color 000000}${offset 20}    Battery
${font Xirod:size=8}${goto -12}${voffset 0}${color 000000}${offset 20}${battery_bar 2,70}
${font Xirod:size=8}${goto -18}${voffset 0}${color 000000}${offset 20}${battery}
${font Xirod:size=8}${goto -12}${voffset 0}${color 000000}${offset 20}${acpiacadapter}
${font Xirod:size=8}${goto -12}${voffset 0}${color 000000}${offset 20}${battery_time}
${font Xirod:size=8}${goto 100}${voffset -35}${color 000000}${offset 20} UP
${font Xirod:size=8}${goto 148}${voffset -12}${color 000000}${offset 20} DOWN
${font Xirod:size=7}${goto 72}${voffset 18}${color 000000}${offset 20}${totalup wlan0}/${upspeed wlan0}
${font Xirod:size=7}${goto 148}${voffset -10}${color 000000}${offset 20}${totaldown wlan0}/${downspeed wlan0}
${font Xirod:size=7}${goto 220}${voffset -60}${color 000000}${offset 20}TCP port open: ${tcp_portmon 1 65535 count}
${font Xirod:size=7}${goto 220}${voffset 2}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  0} ${tcp_portmon 1 65535 rport 0}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  1} ${tcp_portmon 1 65535 rport 1}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  2} ${tcp_portmon 1 65535 rport 2}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  3} ${tcp_portmon 1 65535 rport 3}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  4} ${tcp_portmon 1 65535 rport 4}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  5} ${tcp_portmon 1 65535 rport 5}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  6} ${tcp_portmon 1 65535 rport 6}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  7} ${tcp_portmon 1 65535 rport 7}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  8} ${tcp_portmon 1 65535 rport 8}
${font Xirod:size=7}${goto 220}${voffset 0}${color 000000}${offset 20}${tcp_portmon 1 65535 rip  9} ${tcp_portmon 1 65535 rport 9}
${font Xirod:size=8}${goto 330}${voffset -113}${color 000000}${offset 20}Running Process:  ${running_processes}
${font Xirod:size=7}${goto 320}${voffset 3}${color 000000}${offset 20}${top name 1}${top mem 1} ${top cpu 1}
${font Xirod:size=7}${goto 320}${voffset 0}${color 000000}${offset 20}${top name 2}${top mem 2} ${top cpu 2}
${font Xirod:size=7}${goto 320}${voffset 0}${color 000000}${offset 20}${top name 3}${top mem 3} ${top cpu 3}

${font Xirod:size=7}${goto 320}${voffset 0}${color 000000}${offset 20}${top_mem name 1}${top_mem cpu 1}${top_mem mem 1}
${font Xirod:size=7}${goto 320}${voffset 0}${color 000000}${offset 20}${top_mem name 2}${top_mem cpu 2}${top_mem mem 2}
${font Xirod:size=7}${goto 320}${voffset 0}${color 000000}${offset 20}${top_mem name 3}${top_mem cpu 3}${top_mem mem 3}



${color 000000}Winnipeg Weather${hr 2}$color${execi 600 bash /home/bry2k200/.accuweather/accuw_script}


${color 000000}${font Xirod:size=10}${execi 600  sed -n '2p' /home/bry2k200/.accuweather/curr_cond}${goto 45}${voffset -10}Currently: ${execpi 600 sed -n '4p' /home/bry2k200/.accuweather/curr_cond}°C
${goto 45}${execpi 600 sed -n '3p' /home/bry2k200/.accuweather/curr_cond|fold -w30}

${color 000000}${font Xirod:size=10}${execi 600  sed -n '2p' /home/bry2k200/.accuweather/tod_ton}${voffset -45}${goto 235}${execpi 600 sed -n '1p' /home/bry2k200/.accuweather/tod_ton}: ${execpi 600 sed -n '4p' /home/bry2k200/.accuweather/tod_ton}°C/${execpi 600 sed -n '5p' /home/bry2k200/.accuweather/tod_ton}°C
${goto 235}${execpi 600 sed -n '3p' /home/bry2k200/.accuweather/tod_ton|fold -w30}

${color 000000}${font Xirod:size=10}${execi 600  sed -n '7p' /home/bry2k200/.accuweather/tod_ton}${voffset -45}${goto 395}${execpi 600 sed -n '6p' /home/bry2k200/.accuweather/tod_ton}: ${execpi 600 sed -n '9p' /home/bry2k200/.accuweather/tod_ton}°C/${execpi 600 sed -n '10p' /home/bry2k200/.accuweather/tod_ton}°C
${goto 395}${execpi 600 sed -n '8p' /home/bry2k200/.accuweather/tod_ton|fold -w30


Script:
Code:

#!/bin/bash

#function: test_image_day
test_image_day () {
    case $1 in
         su)
           echo a
         ;;
         msu)
           echo b
         ;;
         psu)
           echo c
         ;;
         ic)
           echo c
         ;;
         h)
           echo c
         ;;
         mc)
           echo d
         ;;
         c)
           echo e
         ;;
         d)
           echo e
         ;;
         f)
           echo 0
         ;;
         s)
           echo h
         ;;
         mcs)
           echo g
         ;;
         psus)
           echo g
         ;;
         t)
           echo l
         ;;
         mct)
           echo k
         ;;
         psut)
           echo k
         ;;
         r)
           echo i
         ;;
         fl)
           echo p
         ;;
         mcfl)
           echo o
         ;;
         psfl)
           echo o
         ;;
         sn)
           echo r
         ;;
         mcsn)
           echo o
         ;;
         i)
           echo E
         ;;
         sl)
           echo u
         ;;
         fr)
           echo i
         ;;
         rsn)
           echo v
         ;;
         w)
           echo 6
         ;;
         ho)
           echo 5
         ;;
         co)
           echo E
         ;;
         cl)
           echo A
         ;;
         mcl)
           echo B
         ;;
         pc)
           echo C
         ;;
         pcs)
           echo G
         ;;
         pct)
           echo K
         ;;
        esac
}

#function: test_image_night
test_image_night () {
    case $1 in
       su)
           echo a
         ;;
         msu)
           echo b
         ;;
         psu)
           echo c
         ;;
         c)
           echo f
         ;;
         d)
           echo f
         ;;
         f)
           echo f
         ;;
         s)
           echo h
         ;;
         psus)
           echo g
         ;;
         t)
           echo l
         ;;
         psut)
           echo k
         ;;
         r)
           echo i
         ;;
         fl)
           echo p
         ;;
         psfl)
           echo o
         ;;
         sn)
           echo r
         ;;
         i)
           echo E
         ;;
         sl)
           echo u
         ;;
         fr)
           echo i
         ;;
         rsn)
           echo v
         ;;
         ho)
           echo 5
         ;;
         co)
           echo E
         ;;
         cl)
           echo A
         ;;
         w)
           echo 6
         ;;
         mcl)
           echo B
         ;;
         pc)
           echo C
         ;;
         ic)
           echo B
         ;;
         h)
           echo B
         ;;
         mc)
           echo C
         ;;
         pcs)
           echo G
         ;;
         mcs)
           echo G
         ;;
         pct)
           echo K
         ;;
         mct)
           echo K
         ;;
         mcfl)
           echo O
         ;;
         mcsn)
           echo O
         ;;
        esac
}

kill -STOP $(pidof conky)
killall wget

#put your Accuweather address here
address="https://www.accuweather.com/en/ca/winnipeg/r3e/weather-forecast/48989"

loc_id=$(echo $address|sed 's/\/weather-forecast.*$//'|sed 's/^.*\///')
last_number=$(echo $address|sed 's/^.*\///')

curr_addr="$(echo $address|sed 's/weather-forecast.*$//')"current-weather/"$last_number"
wget -O $HOME/.accuweather/curr_cond_raw "$curr_addr"

addr1="$(echo $address|sed 's/weather-forecast.*$//')"daily-weather-forecast/"$last_number"
wget -O $HOME/.accuweather/tod_ton_raw "$addr1"

#current conditions
if [[ -s $HOME/.accuweather/curr_cond_raw ]]; then

    sed -i '/detail-now/,/#details/!d' $HOME/.accuweather/curr_cond_raw
    egrep -i '"cond"|icon i-|detail-tab-panel' $HOME/.accuweather/curr_cond_raw > $HOME/.accuweather/curr_cond
    sed -i -e 's/^.*detail-tab-panel //g' -e 's/^.*icon i-//g' -e 's/"><\/div>.*$//g' $HOME/.accuweather/curr_cond
    sed -i -e 's/^.*"cond">//g' -e 's/&deg/\n/g' -e 's/<\/span>.*"temp">/\n/g' -e 's/<.*>//g' $HOME/.accuweather/curr_cond
    sed -i -e 's/">//g' -e 's/-->//g' -e 's/\r$//g' -e 's/ i-alarm.*$//g' $HOME/.accuweather/curr_cond
   time=$(sed -n 1p $HOME/.accuweather/curr_cond)
    image=$(sed -n 2p $HOME/.accuweather/curr_cond)
   if [[ $time == day ]]; then
       sed -i 2s/$image/$(test_image_day $image)/ $HOME/.accuweather/curr_cond
   elif [[ $time == night ]]; then
       sed -i 2s/$image/$(test_image_night $image)/ $HOME/.accuweather/curr_cond
   fi

fi

#First 5 days
if [[ -s $HOME/.accuweather/tod_ton_raw ]]; then

    sed -i '/feed-tabs/,/\.feed-tabs/!d' $HOME/.accuweather/tod_ton_raw
    egrep -i 'Early AM|Today|Tonight|Overnight|icon i-|cond|temp|Mon|Tue|Wed|Thu|Fri|Sat|Sun' $HOME/.accuweather/tod_ton_raw > $HOME/.accuweather/tod_ton
    sed -i -e 's/^.*#">//g' -e 's/^.*icon i-//g' -e 's/^.*cond">//g' -e 's/^.*temp">//g' $HOME/.accuweather/tod_ton
    sed -i -e 's/Lo<\/span> /\n/g' -e 's/<\/a>.*$//g' -e 's/ "><.*$//g' -e 's/&#.*$//g' -e 's/teo//g' $HOME/.accuweather/tod_ton
    sed -i -e 's/<span>.*$//g' -e 's/<\/span>//g' -e 's/\r$//g' -e 's/ i-alarm.*$//g' $HOME/.accuweather/tod_ton
   sed -i -e 's/Early AM/EARLY AM/' -e 's/Today/TODAY/' -e 's/Tonight/TONIGHT/' -e 's/Overnight/OVERNIGHT/' -e 's/Mon/MONDAY/' -e 's/Tue/TUESDAY/' -e 's/Wed/WEDNESDAY/' -e 's/Thu/THURSDAY/' -e 's/Fri/FRIDAY/' -e 's/Sat/SATURDAY/' -e 's/Sun/SUNDAY/' $HOME/.accuweather/tod_ton
    time=$(sed -n 1p $HOME/.accuweather/tod_ton)
    image=$(sed -n 2p $HOME/.accuweather/tod_ton)
   if [[ $time == TODAY ]]; then
       sed -i 2s/$image/$(test_image_day $image)/ $HOME/.accuweather/tod_ton
   elif [[ $time == TONIGHT || $time == OVERNIGHT || $time == "EARLY AM" ]]; then
       sed -i 2s/$image/$(test_image_night $image)/ $HOME/.accuweather/tod_ton
        sed -i 3a- $HOME/.accuweather/tod_ton
   fi
    for (( i=7; i<=22; i+=5 ))
     do
          image=$(sed -n "${i}"p $HOME/.accuweather/tod_ton)
         sed -i ${i}s/$image/$(test_image_day $image)/ $HOME/.accuweather/tod_ton
     done

fi


kill -CONT $(pidof conky)
Back to top
View user's profile Send private message
nbrogan
n00b
n00b


Joined: 15 Apr 2017
Posts: 5

PostPosted: Mon May 01, 2017 4:28 pm    Post subject: Reply with quote

I was having a similar issue, and I think Accuweather is actually down, it won't load for me at all.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Mon May 01, 2017 4:36 pm    Post subject: Reply with quote

FWIW, it works here. I believe I use the same script, have vague memories debugging it to make it work when I set it up in past.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum