#!/bin/bash

# Specify your location (e.g., London or London,GB)
LOCATION="your_location_here"

# Fetch weather data from wttr.in
RESPONSE=$(curl -s "wttr.in/${LOCATION}?format=1")

# Fetch additional detailed weather information
DETAIL=$(curl -s "wttr.in/${LOCATION}?format=%C+%t+%w+%p+%S")

# Parse the response
CONDITION=$(echo "$DETAIL" | awk '{print $1}')
TEMP=$(echo "$DETAIL" | awk '{print $2}')
WIND=$(echo "$DETAIL" | awk '{print $3}')
PRESSURE=$(echo "$DETAIL" | awk '{print $4}')
SUNRISE=$(echo "$DETAIL" | awk '{print $5}' | cut -d' ' -f1)
SUNSET=$(echo "$DETAIL" | awk '{print $5}' | cut -d' ' -f2)

# FontAwesome icons (replace with actual icons as needed)
ICON_CONDITION="☀️"  # Use a default icon
if [[ "$CONDITION" == *"🌧"* ]]; then
    ICON_CONDITION="🌧️"
elif [[ "$CONDITION" == *"☀"* ]]; then
    ICON_CONDITION="☀️"
elif [[ "$CONDITION" == *"🌤"* ]]; then
    ICON_CONDITION="🌤️"
fi

ICON_WIND="🌬️"  # Wind icon
ICON_PRESSURE="🌡️"  # Pressure icon
ICON_SUNRISE="🌅"  # Sunrise icon
ICON_SUNSET="🌇"  # Sunset icon

# Output the weather information
echo "$ICON_CONDITION $TEMP, $ICON_WIND $WIND, $ICON_PRESSURE $PRESSURE, $ICON_SUNRISE $SUNRISE, $ICON_SUNSET $SUNSET"
