Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 23 May 2013, 09:10
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
Desktop weather script tutorial.
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Sat 01 Jan 2011, 13:39    Post subject:  Desktop weather script tutorial.  

I will split this tutorial into two parts:
Part .1 will deal with setting up the needed scripts.
Part .2 will deal with setting the scripts to automatically run/update at boot and then every hour after.

This tutorial is aimed at Lucid Puppy as this is what i am using, although the set up is relatively simply so it will probably work on other versions of puppy to.

Before i start - this Script relies on informations from the website http://weather.noaa.gov/ please visit this site first and ensure you can find a suitable weather station at or near your location before proceeding. (If you have found a suitable weather station please bookmark the page in your web browser as we will need to re-visit the page in step .2 of this tutorial)

Desktop Weather Script.

Desktop Weather Script is a simple weather script for Puppy Linux, it will download from the internet the current weather conditions for your local area and display that information on your desktop in an xmessage window.



Step 1.

First thing to do is create two new Scripts in /root/my-applications/bin
Name Script one: weather.get
Name Script two: weather.show



*If you are unsure on how to create a Script navigate to /root/my-applications/bin with Rox file manager.
Then inside the Rox file manager window Right mouse button click>New>Script


Step 2.

Script one: weather.get
Open the weather.get script with Geany text editor.
*If you are unsure on how to open a Script in text editor - navigate to the script with Rox file manager then on the Script you wish to open Right mouse button click>File'Script name'>Open as Text

Now you have the weather.get Script open in Geany text editor copy (Ctrl + c) and paste (Ctrl + v) the below code but don't save yet.

Code for weather.get
Code:
#!/bin/sh

if [ /root/forecast.txt ];then
 rm /root/forecast.txt
fi

wget -O forecast.txt http://weather.noaa.gov/pub/data/observations/metar/decoded/EGXE.TXT


Now we need to edit the code in your weather.get script to get the weather information for your location.

Please visit the http://weather.noaa.gov/ local weather station page you bookmarked before starting this tutorial.

On the webpage you will see a code, this code is for your local weather station.


You need to copy this code (Ctrl + c) and paste (Ctrl + v) it into your weather.get Script.



*Make sure to delet the code that is already in your weather.get script as this is the code for my local weather station.

When you have done this in the Geany text editor save the weather.get Script.


Step 3.

Script two: weather.show
Open the weather.show script with Geany text editor.

Now you have the weather.show Script open in Geany text editor copy (Ctrl + c) and paste (Ctrl + v) the below code but don't save yet.

Code for weather.show
Code:
#!/bin/sh

xmessage -buttons "5 Day Forecast:1,10 Day Forecast:2,Exit:3" -fg "#333333" -bg "#E7E7E7" -center -title Weather -file /root/forecast.txt -timeout 18 



case $? in
    1)
   defaultbrowser http://news.bbc.co.uk/weather/forecast/340
   ;;
       2)
   defaultbrowser http://uk.weather.com/weather/10day-Leeming-ukxx0173
   ;;
esac


Now we need to set the weather.show Script for you local area - In the above code you will see two website addresses - these are the web addresses for a 5 day and 10 day forecasts, when you click on these in the forecast xmessage window they will automatically open your web browser and load the respective web pages for a 5 and 10 day forecast.

As the 5 and 10 day forecasts are displayed in your web browser you can use any website you like that provides the forecast for your local area.



Once you have found suitable 5 and 10 day weather forecast for your local area you will need to copy (Ctrl + c) and paste (Ctrl + v) the full website address into your weather.show Script code.

*Make sure to delet the website address code that is already in your weather.show script as this is the code for my local weather station.

The defaultbrowser section in the weather.show script are to launch what ever web browser you have installed in Puppy as default - however you can change this to use which ever web browser you like - simply replace 'defaultbrowser' with the path to an executable of the web browser of your choosing - The web browser executable are usualy located in /usr/bin

When you have done this in the Geany text editor save the weather.show Script.


Step .4

This step is for JWM windows manager.

Now we have the weather.show script set for your local area other than clicking directly on the weather.show script or typing weather.show in rxvt terminal we need a convenient way to launch it from the desktop.

In Rox file manager navigate to your /root directory and open the .jwmrc-tray file in Geany text editor.

*If you do not see a .jwmrc-tray file in/root in a clear area of the Rox file manager window Right mouse button click>Display>Show Hidden

Copy the below code into your .jwmrc-tray file (my preferred location for this code is just in front of the clock code)

Code:
<TrayButton label="W">exec:/root/my-applications/bin/weather.show</TrayButton>



When you have done this in the Geany text editor save the .jwmrc-tray file.

The above will add a 'W' for weather just infront of the clock in the JWM tray click on the 'W' will launch your weather.show Script.
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Sat 01 Jan 2011, 14:09    Post subject:  

Part 2.

Step 1.

To have the weather.get Script automaticly run at boot up we need to make a link to the Startup directory located in /root

To do this, in Rox File manager navigate to /root/Startup open another instance of Rox file manager and this time navigate to /root/my-applications/bin now we need to drag and drop the weather.get Script from /root/my-applications/bin to /root/Startup doing this will open a selection box - select Link (absolute)




Step 2.

To have the weather.get Script automatically update the weather forecast information every hour we now need to add a new task to Pschedule.

To open Pschedule mouse click on Menu>System>Pschedule on time.



1. In Pschedule click the 'add task' button to add a new task.

2. command - the command is the location of your weather.get Script copy (Ctrl + c) and paste (Ctrl + v) the Script location /root/my-applications/bin/weather.get

3. Task name - is the name of the Task we are adding to Pschedule - just call it weather.

4. Time - this is to update every hour - select 01 in the Min collum

5. click OK to save the Task.


Step .3

With Pschedule still open it is now time to test the Scripts Mouse click on the run button.

If every thing has worked and gone as planed when you click the 'W' button in the JWM tray you should get your local weather forecast and the option for 5 day and 10 day weather forecasts.



Smile
Back to top
View user's profile Send private message 
rokytnji


Joined: 20 Jan 2009
Posts: 745
Location: Pecos/ Texas

PostPosted: Thu 29 Sep 2011, 19:42    Post subject:  

Worked Like a Charm in Puppy 520 Wink
2011-09-29_23-41-34-thumb.jpg
 Description   
 Filesize   63.82 KB
 Viewed   1252 Time(s)

2011-09-29_23-41-34-thumb.jpg

Back to top
View user's profile Send private message Visit poster's website 
Zeittriven

Joined: 12 Oct 2011
Posts: 1

PostPosted: Wed 12 Oct 2011, 12:56    Post subject:  

rokytnji wrote:
Worked Like a Charm in Puppy 520 Wink

Indeed, tried it - works perfectly. Many thanx

Last edited by Zeittriven on Sat 22 Oct 2011, 12:09; edited 1 time in total
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1230
Location: Ukraine

PostPosted: Wed 12 Oct 2011, 13:21    Post subject:  

Dear Stu,

Thanks for this little applet. You can spare the scripts if you use the following little prog I wrote (bweather) a while back. It is 34k, so your method is probably more efficient...Smile

With kind regards,
vovchik
bweather.tar.gz
Description 
gz

 Download 
Filename  bweather.tar.gz 
Filesize  13.3 KB 
Downloaded  138 Time(s) 
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Thu 13 Oct 2011, 10:38    Post subject:  

vovchik wrote:
Dear Stu,

Thanks for this little applet. You can spare the scripts if you use the following little prog I wrote (bweather) a while back. It is 34k, so your method is probably more efficient...Smile

With kind regards,
vovchik


Thanks vovchik,
I use conky now for my weather but your bweather works great and very easy to setup.

one little thing - i get these funny looking letters at top?
ÈèØm·Øm·àm·àm·èm·èm·ðm·ðm·øm·øm·
Not sure what they mean but i can live with them.

-----------------------------------------------------------
Quick guide for adding vovchik's bweather to ./bashrc

1. Copy bweather executable to /usr/bin

2. Open in text editor /root/.bashrc file and copy below to it (making sure to add your own location code) :
alias weather="bweather Location Code"

3. Enter ~/.bashrc command in terminal to reload ./bashrc

4. Open new terminal and enter weather to get current weather Smile
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1230
Location: Ukraine

PostPosted: Thu 13 Oct 2011, 11:04    Post subject:  

Dear Stu,

I also noticed those letters some time ago and did a revision of bweather to filter them out. I must have posted an older version and will now try to find the one that does the appropriate filtering.... Smile

With kind regards,
vovchik

PS. Those weird symbols started appearing after I wrote the original version. I think metar must have changed something in the mean time but it is nothing too dramatic (perhaps to accommodate UTF-8?).
Back to top
View user's profile Send private message 
tomo3

Joined: 26 Jul 2010
Posts: 8

PostPosted: Sun 16 Oct 2011, 03:05    Post subject:  

Worked Like Charm in Slacko Very Happy

01micko "Xdialog and pick an icon based on the Weather" and I adds a "weather"icon to JWM tray----.

weather.pet(EGXE,no jwm)
weather.png
Description 
png

 Download 
Filename  weather.png 
Filesize  153.98 KB 
Downloaded  150 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0766s ][ Queries: 13 (0.0122s) ][ GZIP on ]