fork download
  1. #!/bin/bash
  2. # Based on http://o...content-available-to-author-only...p.org/current
  3. #для иконок нужен шрифт awesome
  4.  
  5. API_KEY="тут ключ"
  6.  
  7. # Check on http://o...content-available-to-author-only...p.org/find
  8. #используя без i3block можно сделать так
  9. #CITY_ID="айди_города"
  10. #соответственно в WEATHER_URL тоже подставить свой айди
  11. #WEATHER_URL="http://a...content-available-to-author-only...p.org/data/2.5/weather?id=айди_города&appid=${API_KEY}&units=metric"
  12. CITY_ID="${BLOCK_INSTANCE}"
  13.  
  14. URGENT_LOWER=0
  15. URGENT_HIGHER=30
  16.  
  17. ICON_SUNNY=""
  18. ICON_CLOUDY=""
  19. ICON_RAINY=""
  20. ICON_STORM=""
  21. ICON_SNOW=""
  22. ICON_FOG=""
  23.  
  24. SYMBOL_CELSIUS="°C"
  25.  
  26.  
  27. WEATHER_URL="http://a...content-available-to-author-only...p.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"
  28.  
  29. WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
  30. WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[a-Z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
  31. WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')
  32.  
  33. if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
  34. echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  35. echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  36. echo ""
  37. elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
  38. echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  39. echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  40. echo ""
  41. elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
  42. echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  43. echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  44. echo ""
  45. elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
  46. echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  47. echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  48. echo ""
  49. elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then
  50. echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  51. echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  52. echo ""
  53. else
  54. echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  55. echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
  56. echo ""
  57. fi
Success #stdin #stdout #stderr 0s 5880KB
stdin
Standard input is empty
stdout
 °C
 °C

stderr
./prog.sh: line 29: wget: command not found