Advertisement
ichase

accuw_USA_script

Oct 21st, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #function: test_image
  4. test_image () {
  5. case $1 in
  6. c|d|f)
  7. echo e
  8. ;;
  9. fl|sn)
  10. echo q
  11. ;;
  12. cl)
  13. echo A
  14. ;;
  15. pc)
  16. echo C
  17. ;;
  18. co)
  19. echo E
  20. ;;
  21. fr|r)
  22. echo i
  23. ;;
  24. h|ic)
  25. echo b
  26. ;;
  27. ho)
  28. echo 5
  29. ;;
  30. i)
  31. echo r
  32. ;;
  33. mcl)
  34. echo B
  35. ;;
  36. mc)
  37. echo c
  38. ;;
  39. mcfl|mcsn|psfl)
  40. echo o
  41. ;;
  42. mcs)
  43. echo g
  44. ;;
  45. pcs)
  46. echo G
  47. ;;
  48. mct|psut)
  49. echo k
  50. ;;
  51. pct)
  52. echo K
  53. ;;
  54. msu|psu)
  55. echo b
  56. ;;
  57. psus)
  58. echo g
  59. ;;
  60. s)
  61. echo h
  62. ;;
  63. rsn|sl)
  64. echo x
  65. ;;
  66. su)
  67. echo a
  68. ;;
  69. t)
  70. echo m
  71. ;;
  72. w)
  73. echo 6
  74. ;;
  75. esac
  76. }
  77.  
  78. wget -O ~/accuweather_conky_USA/raw http://www.accuweather.com/us/va/virginia-beach/23451/forecast-details.asp
  79. sed -i '/feed-tabs/,/\/.feed-tabs/!d' ~/accuweather_conky_USA/raw
  80.  
  81. #file: days
  82. grep '#' ~/accuweather_conky_USA/raw > ~/accuweather_conky_USA/days
  83. sed -i 's/<\|>/\n/g' ~/accuweather_conky_USA/days
  84. sed -i '/Today\|Tonight\|Overnight\|Tomorrow\|Monday\|Tuesday\|Wednesday\|Thursday\|Friday\|Saturday\|Sunday/!d' ~/accuweather_conky_USA/days
  85.  
  86. #file: messages
  87. grep 'cond' ~/accuweather_conky_USA/raw > ~/accuweather_conky_USA/messages
  88. sed -i 's/<\|>/\n/g' ~/accuweather_conky_USA/messages
  89. sed -i '/span class="cond"\|\/span/d' ~/accuweather_conky_USA/messages
  90.  
  91. #file: temperatures
  92. grep 'temp' ~/accuweather_conky_USA/raw > ~/accuweather_conky_USA/temperatures
  93. sed -i 's/"temp">\|<span>&\|&\|<\/span>\ /\n/g' ~/accuweather_conky_USA/temperatures
  94. sed -i '/<strong class=\|deg;<\/span><\/strong><span class="low"><span>Lo\|deg;<\/span>/d' ~/accuweather_conky_USA/temperatures
  95. day1=$(sed -n '1p' ~/accuweather_conky_USA/days)
  96. if [[ $day1 == Overnight || $day1 == Tonight ]]; then
  97. sed -i 1i"-" ~/accuweather_conky_USA/temperatures
  98. fi
  99.  
  100. #file: images
  101. grep 'icon' ~/accuweather_conky_USA/raw > ~/accuweather_conky_USA/images
  102. sed -i 's/\ i-alarm//g' ~/accuweather_conky_USA/images
  103. sed -i 's/\ i-\|"></\n/g' ~/accuweather_conky_USA/images
  104. sed -i '/<div class="icon\|\/div>/d' ~/accuweather_conky_USA/images
  105. for (( i=1; i<=5; i++ ))
  106. do
  107. test_number=$(sed -n "${i}p" ~/accuweather_conky_USA/images)
  108. test_image $test_number >> ~/accuweather_conky_USA/images
  109. done
  110. messag1=$(sed -n '1p' ~/accuweather_conky_USA/days)
  111. if [[ $messag1 == Tonight || $messag1 == Overnight ]]; then
  112. imag1=$(sed -n '1p' ~/accuweather_conky_USA/images)
  113. case $imag1 in
  114. h|ic)
  115. sed -i '6s/b/B/' ~/accuweather_conky_USA/images
  116. ;;
  117. mc)
  118. sed -i '6s/c/C/' ~/accuweather_conky_USA/images
  119. ;;
  120. mcfl|mcsn)
  121. sed -i '6s/o/O/' ~/accuweather_conky_USA/images
  122. ;;
  123. mcs)
  124. sed -i '6s/g/G/' ~/accuweather_conky_USA/images
  125. ;;
  126. mct)
  127. sed -i '6s/k/K/' ~/accuweather_conky_USA/images
  128. ;;
  129. esac
  130. fi
  131.  
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement