Skip to content

Instantly share code, notes, and snippets.

@umberto10
Created April 1, 2022 12:14
Show Gist options
  • Save umberto10/4d0531a720829611adb89c8a22d3f1ba to your computer and use it in GitHub Desktop.
Save umberto10/4d0531a720829611adb89c8a22d3f1ba to your computer and use it in GitHub Desktop.
choose city and get the current icm weather png
#!/usr/bin/bash
set -e
FN='/tmp/icm.png'
JSON=$(curl -s 'https://m.meteo.pl/ajax/0?weather_type=60&query=' -H 'Accept: text/plain, */*; q=0.01' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: https://m.meteo.pl/')
CITY=$(echo -e ${JSON}|jq -r '[.suggestions[].value] | join("\n")'|dmenu -i)
CITY_DAT=$(echo -e ${JSON} | jq -r ".suggestions[] | select(.value==\"${CITY}\") | .data")
EXT=""
BASE="${CITY_DAT%%:*}"
[[ "${CITY_DAT}" =~ ":" ]] && EXT="${CITY_DAT##*:}";
URL="${BASE}/60/${EXT}"
echo "Getting weather chart..."
curl -s "https://m.meteo.pl/${URL}"|grep 'image_60'|tr '"' '\n'|grep 'https'| wget -q -nv -O ${FN} -i-
echo "Weather for ${CITY}"
feh ${FN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment