Real time weather app (DIY)

I have been searching for a nice weather desktop app but found it either too heavy, requiring API key, or the scripts are outdated. The latter was more in my line to be adding to Yad buttons. In my search, find something much better. Two bash commands that take a screenshot directly of a weather website. Instead of text extract, takes a screenshot without opening a web browser. Then crop the screenshot of a selected area. (It requires cutycapt and ImageMagick).

cutycapt --out=timeDate.png
convert timeDate.png -crop 540x480+0+840 timeDataCONVER.png

Here are screenshots of how the weather app will look in FVWM and XFCE (any DE or WM). This is the test script with the crop, append, and text addon that needs improvement, hopefully, someone could help. The script works but does not look “professional”. :wink:

When ready, I will upload a zip file with full content.

#! /bin/bash
## By Rasat 5 April 2023
## Weather website image and cropping.

## Check connection
ping -q -c1 &>/dev/null && echo online || test="offline"
	if [ $test = offline ]; then
	yad --width=300 --height=30 --title="Alert" --text-align=center  \
	--text="<b>You are offline, check or your device connection.</b>" --button=Close:0

cd ~/.fvwm/extraEXT/MODULES/WeatherB/
echo "loading..." > load.tmp

## Location
PLACE=$(awk '{ print $1 }' location/country-city.txt | sed 's/|/,/g;s/.$//' location/country-city.txt)

echo $PLACE > location.txt

## Link
URL=$(sed 's/,/\//' location.txt) 

## Screenshot
cutycapt$URL --out=cache/timeDateWEB.png # 803x2990

## Crop, (width x height + left + top), resize and button icon
convert cache/timeDateWEB.png -crop 392x335+0+840 cache/timeDateCRP.png
convert cache/timeDateWEB.png -crop 130x200+10+345 -resize 124x image/timeDateCRP-tmb.png # 124x191
convert cache/timeDateWEB.png -crop 76x76+27+668 image/timeDateICON.png

## Append vertical (-append) and horisontal (+append) and add location lable.
convert image/timeDateCRP-tmb.png image/blue124x135.png -pointsize 13 \
-annotate +10+18 $PLACE -append cache/blueNOW.png # image/blue124x335.png

convert cache/timeDateCRP.png cache/blueNOW.png +append image/timeDateNOW.png

yad --title="TDWeather" --image=image/timeDateNOW.png --fontname="DejaVu Sans Mono Book 10" \
    --button='Setting:bash -c "./location/"' \
    --button='Restart:bash -c "killall -SIGUSR1 fvwm3"' \
    --button=gtk-close:0 --undecorated

#! /bin/bash
cp location/country-city.txt location/country-city.bkp

LOC=$(awk '{ print $1 }' location/country-city.txt | sed 's/|/ /g' location/country-city.txt)
echo $LOC > location.txt
CONT=$(awk '{ print $1 }' location.txt)
CITY=$(awk '{ print $2 }' location.txt)

URL=$(sed 's/,/\//' location.txt) 

yad --width=400 --title="WSettting" --text="<big><b>Enter location:</b></big>" --form --field="Country":TEXT "$CONT" > location/country-city.txt --field="City":TEXT "$CITY" > location/country-city.txt --button=Cancel:1 --button=Ok:0

if [ $? -ne 0 ]; then
cp location/country-city.bkp location/country-city.txt




Cool @rasat , odly enough @Sector11 & I were checking them out in the weather thread a little while ago.

Most excellent, thanks for the share.


Nice work thanks.
I would like a live weather wallpaper?

Great, also on MX Linux a few were asking. Been a long winter, want to know when the summer is coming. :sunny:

Needs a major improvement, from MX comments, takes a long time to connect the website and get the screenshot. Needs a background load that also updates the icon and thumbnail on the desktop. I am now checking on how to run bash script as a daemon in the background.

Oh, I wasn t aware of that since it s been years that I haven t looked at their forum, thx for sharing, we might find ideas here & there with those threads.

I’ll be following and playing with this. :))

I see that timeanddata uses the ICAO code of nearby airfields. In my case I have two (7602423; 2878037). However, these are so far away from me that I cannot use them. I have already noticed this in the conky again and again, because the data does not match the location.

exec 2>/dev/null
cutycapt --out=timeDate.png
convert timeDate.png -crop 540x480+0+480 timeDataCONVER.png > /home/unklarer/Wallpaper

1 Like

Works fine as wallpaper, actually quite cool. I did a test on one of my favorite wallpapers. First with one crop image and another by splitting the image into four thumbnails.

NOTE: It took time to find the ImageMagic options, here I included also the details in the headers.

  1. One crop image on wallpaper size 1920x1080
### size: 1000px2686, take screenshot 1053x1080 ###

cutycapt --out=testSHOT.png --min-width=1050 --min-height=1080
convert testSHOT.png -crop 1000x460+0+365 testCRP.png

### Favorit wallpaper (1920x1080) add testCRP.png (-gravity <option> +left+top) ###

convert wallpaperFAV.png testCRP.png -gravity center -geometry -190-55 -composite wallTESTcenter.png


  1. Four thumbnails on wallpaper size 1920x1080
### size: 1000px2686, take screenshot 1053x1080 ###

cutycapt --out=testSHOT.png --min-width=1050 --min-height=1080

### Crop (width x height + left + top) ###

convert testSHOT.png -crop 1000x460+0+365 testCRP.png

### Crop, colorize, resize and thumbnails of info boxes. ###

convert testSHOT.png -crop 260x190+3+375 -fill blue -colorize 6 testBOXnow.png
convert testSHOT.png -crop 262x190+265+375 testBOXinfo.png
convert testSHOT.png -crop 1095x160+0+660 -fill blue -colorize 6 -resize 700x testBOX5hour.png

### Crop and convert the white area to purple-grey ###

convert testSHOT.png -crop 266x140+753+384 -fuzz 5% -fill 'rgb(222,214,225)' -opaque white testBOXmap.png

### Favorit wallpaper (1920x1080) add boximages (-gravity <option> +left+top) ###

convert wallpaperFAV.png testBOXnow.png -gravity west -geometry +294-69 -composite wallTEST.png
convert wallTEST.png testBOXinfo.png -gravity north -geometry -54+106 -composite wallTEST.png
convert wallTEST.png testBOX5hour.png -gravity center -geometry -164+284 -composite wallTEST.png
convert wallTEST.png testBOXmap.png -gravity east -geometry +399-94 -composite wallTEST.png


1 Like

Tried this:

exec 2>/dev/null
cutycapt --out=timeDate.png
convert timeDate.png -crop 540x480+0+480 timeDataCONVER.png > /home/sector11/weatherwall

Does not work at all … /home/sector11/weatherwall remains empty.

HELP Please… Installed:

   $ ser imagemagick cutycapt
i   cutycapt                                                      - utility to capture WebKit's rendering of a web page                    
i   imagemagick                                                   - image manipulation programs -- binaries                                
i A imagemagick-6-common                                          - image manipulation programs -- infrastructure                          
i   imagemagick-6-doc                                             - document files of ImageMagick                                          
i A imagemagick-6.q16                                             - image manipulation programs -- quantum depth Q16                       
 08 Apr 23 @ 12:12:20 ~



 08 Apr 23 @ 13:06:18 ~/weatherwall
 08 Apr 23 @ 13:12:29 ~/weatherwall

takes 6 seconds to do something but does nothing

As seen above I cd to ~/weatherwall and from my script i use this line:

cutycapt --out=timeDate.png

works perfect:

The second line has an OOPS!
convert timeDate.png -crop 540x480+0+480 timeDataCONVER.png > /home/sector11/weatherwall

 08 Apr 23 @ 13:18:08 ~/weatherwall
   $ convert timeDate.png -crop 540x480+0+480 timeDataCONVER.png > /home/sector11/weatherwall
bash: /home/sector11/weatherwall: Is a directory
 08 Apr 23 @ 13:20:23 ~/weatherwall

so I take out the ‘redirect’ - looks good until I look at it:



But /home/sector11/bin/ does not work.

08 Apr 23 @ 13:06:18 ~/weatherwall
   $ ./
 08 Apr 23 @ 13:12:29 ~/weatherwall


cd /home/sector11/bin/

I added:
cd ~/weatherwall in the script and it still failed on the convert line:

convert timeDate.png -crop 540x480+0+480 timeDataCONVER.png > /home/sector11/weatherwall

removing the redirect in that line gave me both images.

But now to figure out the -crop because your geometry isn’t working for me:

Code still a bit messy - still playing with it.
I call it: fwall (Feh + WALLpaper)

<< weather - one on my 'goto sites'
Thanks: rasat & unklar

more reading, more tweaking ahead.

for now:
terminal $ fwall
[alt]+[F] [fwall]
OB Menu?  in time

cd /home/sector11/weatherwall
rm *.png
exec 2>/dev/null
cutycapt --url= --out=timeDate.png
convert timeDate.png -crop 777x400+0+380 CABA.png
feh CABA.png &

Thanks guys…

Try this:
replace · with . and a “country name”

Remove command “>”. And the default cutycapt screenshot is 803x3047. To screenshot the full width of website (1000px) add min-width=1050.

cutycapt --min-width=1050 --out=timeDate.png

To crop, specify the geometry (width x height + left + top) and output is dir/name.png

convert timeDate.png -crop 1000x460+0+365 /home/sector11/weatherwall/timeDataCONVER.png

convert timeDate.png -crop 1000x460+0+365 /home/sector11/weatherwall/timeDataCONVER.png

cd  /home/sector11/weatherwall
convert timeDate.png -crop 777x400+0+380 CABA.png

What’s this: @7602423 for?

@unklar @rasat @Sector11

Thanks to all for your input this looks like a lot of fun, be home soon can’t wait to try your work.

By the way Happy Easter

Happy Easter everyone.