elenapan/Scripts/weather.sh
elena e43cf1ccde updated scripts, added configs, new screenshot
Former-commit-id: 80e5a611d9
Former-commit-id: d6d963dd470140b7a955399ff22fec885ddace30
2017-08-29 02:28:24 +03:00

60 lines
No EOL
1.3 KiB
Bash
Executable file

#!/bin/bash
# needs work
CITY="Hamburg"
# glyphs (TODO)
#  day cloud
#  storm
#  night cloud
#  rain
# umbrella 
#  snow 
#  sun
#  cloud
#  moon  star
#   house
#  globe
#  bed
# curl -4 http://wttr.in/@$(curl -s 'https://api.ipify.org?format=plaintext')
TEMP="$(curl -s -A "Mozilla/5.0" wttr.in/$CITY | grep -m 1 '°C'| awk '{print $(NF-1)}' | cut -d ">" -f2 | cut -f1 -d "<")"
# NOTE: Currently weather state disabled. Uncomment to reenable
# STATE="$(curl -s -A "Mozilla/5.0" wttr.in/$CITY | grep -m 1 -B 1 '°C' | sed '$d' | awk '{printf "%s %s", $(NF-1), $NF}')"
# PRELAST="$(echo $STATE | awk '{print $1}')"
# HOUR="$(date +%H)"
# # Check if state is only one word
# if [[ "$PRELAST" = "</span>" ]]; then
# STATE="$(echo $STATE | awk '{print $2}')"
# fi
# if [[ "$STATE" = "Clear" ]]; then
# if [ $HOUR -lt 20 ] && [ $HOUR -gt $5 ]; then
# echo " $TEMP°C"
# else
# echo " $TEMP°C"
# fi
# elif [[ "$STATE" = "Partly cloudy" ]]; then
# if [ $HOUR -lt 20 ] && [ $HOUR -gt 5 ]; then
# echo " $TEMP°C"
# else
# echo " $TEMP°C"
# fi
# elif [[ "$STATE" = "Cloudy" ]]; then
# echo " $TEMP°C"
# elif [[ "$STATE" = "Sunny" ]]; then
# echo " $TEMP°C"
# else
# echo " $TEMP°C"
# fi
# City+degrees
#echo $CITY $TEMP°C
# Degrees only
echo "$TEMP°C"