Advertisement
Guest User

Untitled

a guest
Feb 8th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.73 KB | None | 0 0
  1. r@ngf:~$ cat '/home/r/Accuweather_Conky_Int_ConkyWeatherFont/acc_int_cwfont'
  2. #!/bin/bash
  3.  
  4. #function: test_image_day
  5. test_image_day () {
  6. case $1 in
  7. su)
  8. echo a
  9. ;;
  10. msu)
  11. echo b
  12. ;;
  13. psu)
  14. echo c
  15. ;;
  16. ic)
  17. echo c
  18. ;;
  19. h)
  20. echo c
  21. ;;
  22. mc)
  23. echo d
  24. ;;
  25. c)
  26. echo e
  27. ;;
  28. d)
  29. echo e
  30. ;;
  31. f)
  32. echo 0
  33. ;;
  34. s)
  35. echo h
  36. ;;
  37. mcs)
  38. echo g
  39. ;;
  40. psus)
  41. echo g
  42. ;;
  43. t)
  44. echo l
  45. ;;
  46. mct)
  47. echo k
  48. ;;
  49. psut)
  50. echo k
  51. ;;
  52. r)
  53. echo i
  54. ;;
  55. fl)
  56. echo p
  57. ;;
  58. mcfl)
  59. echo o
  60. ;;
  61. psfl)
  62. echo o
  63. ;;
  64. sn)
  65. echo r
  66. ;;
  67. mcsn)
  68. echo o
  69. ;;
  70. i)
  71. echo E
  72. ;;
  73. sl)
  74. echo u
  75. ;;
  76. fr)
  77. echo i
  78. ;;
  79. rsn)
  80. echo v
  81. ;;
  82. w)
  83. echo 6
  84. ;;
  85. ho)
  86. echo 5
  87. ;;
  88. co)
  89. echo E
  90. ;;
  91. cl)
  92. echo A
  93. ;;
  94. mcl)
  95. echo B
  96. ;;
  97. pc)
  98. echo C
  99. ;;
  100. pcs)
  101. echo G
  102. ;;
  103. pct)
  104. echo K
  105. ;;
  106. esac
  107. }
  108.  
  109. #function: test_image_night
  110. test_image_night () {
  111. case $1 in
  112. su)
  113. echo a
  114. ;;
  115. msu)
  116. echo b
  117. ;;
  118. psu)
  119. echo c
  120. ;;
  121. c)
  122. echo f
  123. ;;
  124. d)
  125. echo f
  126. ;;
  127. f)
  128. echo f
  129. ;;
  130. s)
  131. echo h
  132. ;;
  133. psus)
  134. echo g
  135. ;;
  136. t)
  137. echo l
  138. ;;
  139. psut)
  140. echo k
  141. ;;
  142. r)
  143. echo i
  144. ;;
  145. fl)
  146. echo p
  147. ;;
  148. psfl)
  149. echo o
  150. ;;
  151. sn)
  152. echo r
  153. ;;
  154. i)
  155. echo E
  156. ;;
  157. sl)
  158. echo u
  159. ;;
  160. fr)
  161. echo i
  162. ;;
  163. rsn)
  164. echo v
  165. ;;
  166. ho)
  167. echo 5
  168. ;;
  169. co)
  170. echo E
  171. ;;
  172. cl)
  173. echo A
  174. ;;
  175. w)
  176. echo 6
  177. ;;
  178. mcl)
  179. echo B
  180. ;;
  181. pc)
  182. echo C
  183. ;;
  184. ic)
  185. echo B
  186. ;;
  187. h)
  188. echo B
  189. ;;
  190. mc)
  191. echo C
  192. ;;
  193. pcs)
  194. echo G
  195. ;;
  196. mcs)
  197. echo G
  198. ;;
  199. pct)
  200. echo K
  201. ;;
  202. mct)
  203. echo K
  204. ;;
  205. mcfl)
  206. echo O
  207. ;;
  208. mcsn)
  209. echo O
  210. ;;
  211. esac
  212. }
  213.  
  214.  
  215. #put your Accuweather address here
  216. address="http://www.accuweather.com/en/ua/kiev/324505/current-weather/324505"
  217.  
  218. loc_id=$(echo $address|sed 's/\/weather-forecast.*$//'|sed 's/^.*\///')
  219. last_number=$(echo $address|sed 's/^.*\///')
  220.  
  221. curr_addr="$(echo $address|sed 's/weather-forecast.*$//')"current-weather/"$last_number"
  222. addr1="$(echo $address|sed 's/weather-forecast.*$//')"daily-weather-forecast/"$last_number"
  223. addr2="$addr1"?day=6
  224.  
  225. kill -STOP $(pidof conky)
  226. killall wget
  227.  
  228. wget --save-cookies $HOME/Accuweather_Conky_Int_ConkyWeatherFont/cookie -O $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond_raw $curr_addr
  229. wget --load-cookies $HOME/Accuweather_Conky_Int_ConkyWeatherFont/cookie -O $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days_raw $addr1
  230. wget --load-cookies $HOME/Accuweather_Conky_Int_ConkyWeatherFont/cookie -O $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days_raw $addr2
  231.  
  232. #Current Conditions - curr_cond file
  233. if [[ -s $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond_raw ]]; then
  234.  
  235. 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
  236. 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
  237. sed -i -e 's/^.*"#">//g' -e 's/^.*<strong class="temp"//g' -e 's/^>//g' -e 's/<span>&deg.*$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
  238. 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
  239. 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
  240. 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
  241. 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
  242. 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
  243. 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
  244. sed -i '1,12d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
  245. time=$(sed -n 1p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
  246. if [[ $time == Tonight || $time == Overnight || $time == "Early AM" ]]; then
  247. sed -i 3a- $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
  248. fi
  249. line35=$(sed -n 35p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
  250. sed -i '35d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
  251. sed -i 35a$line35 $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
  252. time=$(sed -n 26p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
  253. image=$(sed -n 27p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
  254. if [[ $time == day ]]; then
  255. sed -i 27s/$image/$(test_image_day $image)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
  256. elif [[ $time == night ]]; then
  257. sed -i 27s/$image/$(test_image_night $image)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond
  258. fi
  259.  
  260. fi
  261.  
  262.  
  263. #First 5days - first_days file
  264. if [[ -s $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days_raw ]]; then
  265.  
  266. sed -i '/<div class="column-1 clearfix">/,/<div id=\"feature-history\">/!d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days_raw
  267. 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
  268. 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
  269. sed -i -e 's/ "><\/div>//g' -e 's/"><\/div>//g' -e 's/^.*"temp">//g' -e 's/<span>&deg.*$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
  270. 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
  271. 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
  272. 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
  273. time=$(sed -n 1p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond)
  274. if [[ $time == Tonight || $time == Overnight || $time == "Early AM" ]]; then
  275. sed -i 2a- $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
  276. fi
  277. L1=$(sed -n 1p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
  278. if [[ $L1 == TODAY ]]; then
  279. sed -i 1d $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
  280. fi
  281. for (( i=6; i<=21; i+=5 ))
  282. do
  283. image_raw=$(sed -n "${i}"p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
  284. sed -i ${i}s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
  285. done
  286. image_raw=$(sed -n 25p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
  287. sed -i 25s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
  288. image_raw=$(sed -n 30p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days)
  289. sed -i 30s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days
  290.  
  291. fi
  292.  
  293.  
  294. #Last 5days - last_days file
  295. if [[ -s $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days_raw ]]; then
  296.  
  297. sed -i '/<div class="column-1 clearfix">/,/<div id=\"feature-history\">/!d' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days_raw
  298. 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
  299. 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
  300. sed -i -e 's/ "><\/div>//g' -e 's/"><\/div>//g' -e 's/^.*"temp">//g' -e 's/<span>&deg.*$//g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
  301. sed -i -e 's/^.*"#">//g' -e 's/\/span> //g' -e 's/^.*>Precipitation //g' -e 's/^.*; //g' $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
  302. 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
  303. 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
  304. for (( i=2; i<=22; i+=5 ))
  305. do
  306. image_raw=$(sed -n "${i}"p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days)
  307. sed -i ${i}s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days
  308. done
  309.  
  310. fi
  311.  
  312. #messages file
  313. sed -n 28p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/curr_cond | cut -c -20 > $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
  314. sed -n 29p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
  315. sed -n 34p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
  316. for (( i=7; i<=22; i+=5 ))
  317. do
  318. sed -n ${i}p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
  319. done
  320. for (( i=3; i<=23; i+=5 ))
  321. do
  322. sed -n ${i}p $HOME/Accuweather_Conky_Int_ConkyWeatherFont/last_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_ConkyWeatherFont/messages
  323. done
  324.  
  325. kill -CONT $(pidof conky)
  326. r@ngf:~$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement