Last active
June 3, 2025 06:44
-
-
Save skorotkiewicz/a4738ca267c16ab455b3bee8768db392 to your computer and use it in GitHub Desktop.
my tint2 executors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ping -c 1 ipv4.google.com | grep -oP 'time=\K[0-9.]+ ms' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LATITUDE=48.8082 | |
LONGITUDE=11.7551 | |
URL="https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${LATITUDE}&lon=${LONGITUDE}" | |
USER_AGENT="Mozilla/5.0 ([email protected])" | |
# Function to get current temperature | |
get_current_temp() { | |
TEMP=$(curl -s -H "User-Agent: $USER_AGENT" "$URL" | \ | |
jq -r '.properties.timeseries[0].data.instant.details.air_temperature') | |
echo "${TEMP}°C" | |
} | |
# Function to display weekly forecast in YAD | |
show_weekly_forecast() { | |
# Fetch weather data | |
WEATHER_DATA=$(curl -s -H "User-Agent: $USER_AGENT" "$URL") | |
# Prepare data for display | |
FORECAST="" | |
# Get forecasts for next 7 days (every 24 hours) | |
for i in {0..6}; do | |
# Calculate index for 24h intervals (API returns hourly data) | |
INDEX=$((i * 24)) | |
# Get data for specific day | |
DATETIME=$(echo "$WEATHER_DATA" | jq -r ".properties.timeseries[$INDEX].time" 2>/dev/null) | |
if [ "$DATETIME" == "null" ] || [ -z "$DATETIME" ]; then | |
continue | |
fi | |
TEMP=$(echo "$WEATHER_DATA" | jq -r ".properties.timeseries[$INDEX].data.instant.details.air_temperature" 2>/dev/null) | |
HUMIDITY=$(echo "$WEATHER_DATA" | jq -r ".properties.timeseries[$INDEX].data.instant.details.relative_humidity" 2>/dev/null) | |
WIND_SPEED=$(echo "$WEATHER_DATA" | jq -r ".properties.timeseries[$INDEX].data.instant.details.wind_speed" 2>/dev/null) | |
# Get weather symbol (if available) | |
SYMBOL=$(echo "$WEATHER_DATA" | jq -r ".properties.timeseries[$INDEX].data.next_1_hours.summary.symbol_code" 2>/dev/null) | |
if [ "$SYMBOL" == "null" ]; then | |
SYMBOL=$(echo "$WEATHER_DATA" | jq -r ".properties.timeseries[$INDEX].data.next_6_hours.summary.symbol_code" 2>/dev/null) | |
fi | |
# Format date | |
DATE=$(date -d "$DATETIME" "+%A, %d.%m.%Y" 2>/dev/null) | |
if [ -z "$DATE" ]; then | |
DATE=$(echo "$DATETIME" | cut -d'T' -f1) | |
fi | |
# Add to forecast | |
FORECAST="${FORECAST}📅 $DATE\n" | |
FORECAST="${FORECAST}🌡️ Temperature: ${TEMP}°C\n" | |
FORECAST="${FORECAST}💧 Humidity: ${HUMIDITY}%\n" | |
FORECAST="${FORECAST}💨 Wind: ${WIND_SPEED} m/s\n" | |
if [ "$SYMBOL" != "null" ] && [ -n "$SYMBOL" ]; then | |
FORECAST="${FORECAST}☁️ Conditions: $SYMBOL\n" | |
fi | |
FORECAST="${FORECAST}\n" | |
done | |
# Display in YAD | |
echo -e "$FORECAST" | yad --text-info \ | |
--title="Weekly Weather Forecast" \ | |
--width=500 \ | |
--height=400 \ | |
--button="Close:0" \ | |
--fontname="Monospace 10" | |
} | |
# Check arguments | |
case "$1" in | |
"forecast") | |
show_weekly_forecast | |
;; | |
*) | |
get_current_temp | |
;; | |
esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LATITUDE=48.8082 | |
LONGITUDE=11.7551 | |
URL="https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${LATITUDE}&lon=${LONGITUDE}" | |
USER_AGENT="Mozilla/5.0 ([email protected])" | |
TEMP=$(curl -s -H "User-Agent: $USER_AGENT" "$URL" | \ | |
jq -r '.properties.timeseries[0].data.instant.details.air_temperature') | |
echo "${TEMP}°C" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment