Gtkdialog: Simple weather app using wttr.in

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
puppy_apprentice
Posts: 662
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 108 times

Gtkdialog: Simple weather app using wttr.in

Post by puppy_apprentice »

Save as eg. weather.sh:

Code: Select all

#!/bin/sh
getWeatherForecast() {
	locale=$(locale -k LC_IDENTIFICATION | grep "category")
	wget -O /tmp/weather.png "wttr.in/$1_lang=${locale:10:2}.png"
}
export -f getWeatherForecast

export MAIN_DIALOG='
<window title="Puppy Weather" icon-name="dialog-information" default_height="518" default_width="1000">
<vbox>
  <hbox>
     <entry>
        <default>Your City</default>
        <variable>ENTRY</variable>
     </entry>
     <button ok>
        <action>getWeatherForecast "$ENTRY"</action>
        <action function="Refresh">pixmap1</action>
     </button>
  </hbox>
  <pixmap>
     <variable>pixmap1</variable>
     <input file>/tmp/weather.png</input>
  </pixmap>
</vbox>
</window>
'

gtkdialog --program=MAIN_DIALOG
puppyweather.jpg
puppyweather.jpg (99.08 KiB) Viewed 248 times
Post Reply

Return to “Programming”