summaryrefslogblamecommitdiff
path: root/weather.sh
blob: 6bd079161bda9103a9c4e1f78c5a57e6f9065b72 (plain) (tree)
1
2
3
4

         

                                                                                            










                                                 


                                                 


                                                 



                                                 

                                                 
                                        

                                                 
                                    

                                                 
                                    

                                                 
                                    



                                                 

                             


                                                          


                                                    









                                                                                                             
                                                                                      
#!/bin/sh

[ "$BLOCK_BUTTON" = 3 ] && $BROWSER 'https://www.windy.com/36.865/-76.468?36.362,-76.468,8' 

API_KEY="$(cat ~/.config/openweathermap)"
ZIP_CODE=23435

while read line
do
	case $line in 
		icon*)
			case "${line#icon }" in 
				01d)
					ICON=󰖙
					;;
				01n)
					ICON=󰖔
					;;
				02d)
					ICON=󰖕
					;;
				02n)
					ICON=󰼱
					;;
				03*|04*)
					ICON=󰖐
					;;
				09*|10*)
					ICON=󰖗
					;;
				11*)
					ICON=󰖓
					;;
				13*)
					ICON=󰖘
					;;
				50*)
					ICON=󰖑
					;;
			esac

			;;
		description*)
			DESCRIPTION="${line#description }"
			;;
		humidity*)
			HUMIDITY="${line#humidity }"
			;;
		feels_like*)
			FEELS_LIKE="${line#feels_like }"
			;;
	esac
done << EOF
$(fetch -qo - "https://api.openweathermap.org/data/2.5/weather?zip=$ZIP_CODE&units=imperial&appid=$API_KEY" \
	| tr -d '"{}[]' \
	| tr ',' '\n' \
	| tr ':' ' ')
EOF

printf "%s %s %2.1f℉ 󰖎 %.2d%%\n" "$ICON" "$DESCRIPTION" "$FEELS_LIKE" "$HUMIDITY"