Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- r@ngf:~$ cat '/home/r/Accuweather_Conky_Int_ConkyWeatherFont/acc_int_cwfont'
- #!/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
- }
- #put your Accuweather address here
- address="http://www.accuweather.com/en/ua/kiev/324505/current-weather/324505"
- 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"
- addr1="$(echo $address|sed 's/weather-forecast.*$//')"daily-weather-forecast/"$last_number"
- addr2="$addr1"?day=6
- kill -STOP $(pidof conky)
- killall wget
- wget --save-cookies $HOME/Accuweather_Conky_Int_ConkyWeatherFont/cookie -O $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond_raw $curr_addr
- wget --load-cookies $HOME/Accuweather_Conky_Int_ConkyWeatherFont/cookie -O $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days_raw $addr1
- wget --load-cookies $HOME/Accuweather_Conky_Int_ConkyWeatherFont/cookie -O $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days_raw $addr2
- #Current Conditions - curr_cond file
- if [[ -s $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond_raw ]]; then
- egrep -i '"detail-tab-panel |>Today<\/a>|>Tonight<\/a>|>Early AM<\/a>|>Overnight<\/a>|>Mon<\/a>|>Tue<\/a>|>Wed<\/a>|>Thu<\/a>|>Fri<\/a>|>Sat<\/a>|>Sun<\/a>|icon i-|"cond"|"temp"|var d = '\''|var s = '\''|Humidity: |Pressure: |Cloud Cover: |UV Index: |Dew Point: |Precipitation(1 hr): |Visibility: |"start">|"finish">' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond_raw > $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/^[ \t]*//g' -e 's/^.*icon i-//g' -e 's/^.*"cond">//g' -e 's/>Lo</\n/g' -e 's/RealFeel/\n/g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/^.*"#">//g' -e 's/^.*<strong class="temp"//g' -e 's/^>//g' -e 's/<span>°.*$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/<\/a>.*$//g' -e 's/\/span> //g' -e 's/var d = //g' -e 's/var s = //g' -e 's/"temp">/\n/g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/^.*"start">//g' -e 's/^.*"finish">//g' -e 's/<li>//g' -e 's/<strong>//g' -e 's/<<span.*$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/<\/span>//g' -e 's/<\/strong><\/li>//g' -e 's/ "><\/div>//g' -e 's/'\''//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/"><\/div>//g' -e 's/^.*; //g' -e 's/&#.*$//g' -e 's/ i-alarm.*$//g' -e 's/;//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/Humidity: //g' -e 's/Pressure: //g' -e 's/Cloud Cover: //g' -e 's/UV Index: //g' -e 's/Dew Point: //g' -e 's/Visibility: //g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i -e 's/^.*detail-tab-panel //g' -e 's/">//g' -e 's/\r//g' -e 's/ *$//g' -e 's/ mb.*$/ mb/g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i '1,12d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- time=$(sed -n 1p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
- if [[ $time == Tonight || $time == Overnight || $time == "Early AM" ]]; then
- sed -i 3a- $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- fi
- line35=$(sed -n 35p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
- sed -i '35d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- sed -i 35a$line35 $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- time=$(sed -n 26p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
- image=$(sed -n 27p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
- if [[ $time == day ]]; then
- sed -i 27s/$image/$(test_image_day $image)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- elif [[ $time == night ]]; then
- sed -i 27s/$image/$(test_image_night $image)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
- fi
- fi
- #First 5days - first_days file
- if [[ -s $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days_raw ]]; then
- sed -i '/<div class="column-1 clearfix">/,/<div id=\"feature-history\">/!d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days_raw
- egrep -i '>Today<|<p>[a-z]|>Mon<\/a>|>Tue<\/a>|>Wed<\/a>|>Thu<\/a>|>Fri<\/a>|>Sat<\/a>|>Sun<\/a>|icon i-|"cond"|"temp"|realfeel">RealFeel|realfeel">Precipitation' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days_raw > $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- sed -i -e 's/^[ \t]*//g' -e 's/^.*icon i-//g' -e 's/^.*"cond">//g' -e 's/>Lo</\n/g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- sed -i -e 's/ "><\/div>//g' -e 's/"><\/div>//g' -e 's/^.*"temp">//g' -e 's/<span>°.*$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- sed -i -e 's/<p>//g' -e 's/<\/p>//g' -e 's/^.*"#">//g' -e 's/\/span> //g' -e 's/^.*>Precipitation //g' -e 's/^.*; //g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- sed -i -e 's/&#.*$//g' -e 's/<.*$//g' -e 's/ i-alarm.*$//g' -e 's/\r//g' -e 's/ *$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- sed -i -e 's/Today/TODAY/' -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_Conky_Int_ConkyWeatherFont/first_days
- time=$(sed -n 1p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
- if [[ $time == Tonight || $time == Overnight || $time == "Early AM" ]]; then
- sed -i 2a- $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- fi
- L1=$(sed -n 1p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
- if [[ $L1 == TODAY ]]; then
- sed -i 1d $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- fi
- for (( i=6; i<=21; i+=5 ))
- do
- image_raw=$(sed -n "${i}"p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
- sed -i ${i}s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- done
- image_raw=$(sed -n 25p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
- sed -i 25s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- image_raw=$(sed -n 30p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
- sed -i 30s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
- fi
- #Last 5days - last_days file
- if [[ -s $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days_raw ]]; then
- sed -i '/<div class="column-1 clearfix">/,/<div id=\"feature-history\">/!d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days_raw
- egrep -i '>Mon<\/a>|>Tue<\/a>|>Wed<\/a>|>Thu<\/a>|>Fri<\/a>|>Sat<\/a>|>Sun<\/a>|icon i-|"cond"|"temp"|realfeel">RealFeel|realfeel">Precipitation' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days_raw > $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
- sed -i -e 's/^[ \t]*//g' -e 's/^.*icon i-//g' -e 's/^.*"cond">//g' -e 's/>Lo</\n/g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
- sed -i -e 's/ "><\/div>//g' -e 's/"><\/div>//g' -e 's/^.*"temp">//g' -e 's/<span>°.*$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
- sed -i -e 's/^.*"#">//g' -e 's/\/span> //g' -e 's/^.*>Precipitation //g' -e 's/^.*; //g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
- sed -i -e 's/&#.*$//g' -e 's/<.*$//g' -e 's/ i-alarm.*$//g' -e 's/\r//g' -e 's/ *$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
- sed -i -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_Conky_Int_ConkyWeatherFont/last_days
- for (( i=2; i<=22; i+=5 ))
- do
- image_raw=$(sed -n "${i}"p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days)
- sed -i ${i}s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
- done
- fi
- #messages file
- sed -n 28p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond | cut -c -20 > $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
- sed -n 29p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
- sed -n 34p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
- for (( i=7; i<=22; i+=5 ))
- do
- sed -n ${i}p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
- done
- for (( i=3; i<=23; i+=5 ))
- do
- sed -n ${i}p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
- done
- kill -CONT $(pidof conky)
- r@ngf:~$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement