#!/usr/bin/env bash # shellcheck disable=SC1090,SC1091 # set -xv EUMETSAT_KEY="jdBM1PsDQUm0tCZfk9VXD6IaJoUa" EUMETSAT_SECRET="SumkiqFMU3MAGpt_azb1KXKgjdMa" error() { printf "\033[31m%s\033[0m\n" "$1" exit 1 } # verify internet ping -c1 1.1.1.1 >>/dev/null || error "couldn't establish an internet connection!" # acquire the output directory if command -v xdg-user-dir; then outdir="$(xdg-user-dir PICTURES)/eumetsat" elif [ -z "$HOME" ]; then outdir="$HOME/.eumetsat" else error "couldn't connect to either 'xdg-user-dir PICTURES' or '\$HOME'" fi # acquire the API key key=$( curl -k -d "grant_type=client_credentials" \ -H "Authorization: Basic $(printf "%s:%s" "$EUMETSAT_KEY" "$EUMETSAT_SECRET" | base64)" \ https://api.eumetsat.int/token | jq -r '.["access_token"]' ) # set url url="https://view.eumetsat.int/geoserver/wms?" url+="&service=WMS" url+="&request=GetMap" url+="&version=1.3.0" url+="&layers=mtg_fd:rgb_geocolour" url+="&width=1080&height=1080" url+="&bbox=-6400000,-6400000,6400000,6400000" url+="&crs=AUTO:42003,9001,0,0" url+="&styles=" url+="&format=image/png" url+="&access_token=$key" # process incoming data [ ! -d "$outdir" ] && { mkdir -p "$outdir" || error "failed to access '$outdir'!"; } curl "$url" -o "$outdir/tmp.png" || error "failed to download from url='$url'!" convert "$outdir/tmp.png" -alpha set -channel RGBA -fuzz 1% -fill none -floodfill +0+0 white "$outdir/curr.png" # update the feh background . "$HOME/.fehbg"