Author Topic: Desktop Weather  (Read 5778 times)

Jan-Erik Lärka

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 11
  • Posts: 151
    • View Profile
Desktop Weather
« on: September 01, 2015, 08:29:04 pm »
Hello,

I've created a rexx script that should show you the current weather.
It has been designed to be used with PNG Desktop as it update the image (icon) and desktop text to describe the current weather and temperature.

The script download png images from the net and use a Smart Guide to guide you through different possible settings you may tweak.

Please do note that you shouldn't make to drastic changes nor to many images (icon) on the desktop as it should be rewritten to handle such situations better. Stop the script in the startup folder and restart it to update the desktop image icon right away. The program object in the startup folder handle updates and you have to delete it by hand if you want to get rid of the desktop image (icon) as well or it will try to recreate it all over again.  ;)
« Last Edit: September 02, 2015, 12:16:06 pm by Jan-Erik Lärka »



Jan-Erik Lärka

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 11
  • Posts: 151
    • View Profile
Re: Desktop Weather
« Reply #1 on: September 01, 2015, 08:31:30 pm »
Example weather

Stop the corresponding script (in the startup folder) if the desktop image (icon) says "Locating..." and animate several times. It indicate that it can't connect and/or fetch data for the location. That is a situation that has to be addressed in the future.
« Last Edit: September 02, 2015, 12:16:36 pm by Jan-Erik Lärka »

Doug Bissett

  • Hero Member
  • *****
  • Thank You
  • -Given: 1
  • -Receive: 38
  • Posts: 924
    • View Profile
Re: Desktop Weather
« Reply #2 on: September 02, 2015, 05:36:27 am »
Quote
I've created a rexx script that should show you the current weather.
It has been designed to be used with PNG Desktop as it update the icon and desktop text to describe the current weather and temperature.

I don't use the PNG desktop (it causes way too many problems), but the script seems to almost work anyway. The location, weather description, and temperature seem to be okay, but the sun icon always shows (even at night).  When I find some time, I may see if I can modify it to use normal OS/2 icons.

The other "problem" that I had, was that the default location selected was 500 KM away from where I live. I was able to use the local coordinates to fix that problem. Is there anything that I can do to determine why it is so far off?

Jan-Erik Lärka

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 11
  • Posts: 151
    • View Profile
Re: Desktop Weather
« Reply #3 on: September 02, 2015, 07:58:43 am »
I've only added a few of the required OS/2 icons (native OS/2 .ico files) to the weather.dll and it doesn't change them in the script (yet) because of that, so you'll only get the sun as it is now.

Anyone who feel like it can create a full set of nice icons (native OS/2 .ico files) can send them to me. ;)

The script use some services to try to locate you. The location is often based on the nearest station that your ISP allow that service to spot, so it may be your ISPs headquarters...
OpenWeather also need to have weather information for the area you live in.
« Last Edit: September 02, 2015, 12:17:34 pm by Jan-Erik Lärka »

Jan-Erik Lärka

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 11
  • Posts: 151
    • View Profile
Re: Desktop Weather
« Reply #4 on: September 02, 2015, 12:40:41 pm »
Ohh, make a copy of bigicons.txt and place it in the bigicons folder in case something happen... like you restart your computer and you have 1+ desktop widget.

Doug Bissett

  • Hero Member
  • *****
  • Thank You
  • -Given: 1
  • -Receive: 38
  • Posts: 924
    • View Profile
Re: Desktop Weather
« Reply #5 on: September 02, 2015, 05:48:16 pm »
Quote
I've only added a few of the required OS/2 icons (native OS/2 .ico files) to the weather.dll and it doesn't change them in the script (yet) because of that, so you'll only get the sun as it is now.

Okay, that explains it...

Quote
Anyone who feel like it can create a full set of nice icons (native OS/2 .ico files) can send them to me. ;)

Where do I get the original icons, or do you mean the ones in Weather.zip? PMView should convert them. Those icons don't seem to be used anyway (but that could be caused by the lack of bigicon support).

Quote
The script use some services to try to locate you. The location is often based on the nearest station that your ISP allow that service to spot, so it may be your ISPs headquarters...
OpenWeather also need to have weather information for the area you live in.

It looks like the problem is with openweather. They only seem to know about major airports (although that doesn't explain why, or how, it chose Lethbridge (500 KM, small city, not listed) over Edmonton (25 KM Capital of Alberta, listed - the airport is about 50 KM from here, and it seems to be in a completely different weather area). The ISP is based in Vancouver (different province, on the other side of a couple of mountain ranges), but the Alberta branch is in Edmonton. Other weather services seem to be able to figure it out.

I also need to know what CityID is supposed to be. Currently, it says "(not_defined" with only one bracket. I would also like to know where that information is stored (I hope it is NOT in one of the system INI files - they grow too big without help).

Quote
Ohh, make a copy of bigicons.txt and place it in the bigicons folder in case something happen... like you restart your computer and you have 1+ desktop widget.

I can find no bigicons.txt or bigicons folder, but that could be because I don't use bigicons. I do see a new icon added to the desktop at every program restart. The new icon is always in the upper left corner, partly off screen, which causes a scroll bar to appear (including when it updates, if I don't move it). If I accidentally click the scroll bar, it moves all of my icons to the right. It also always goes through the setup, even though the data is obviously stored somewhere.

Thanks...

Jan-Erik Lärka

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 11
  • Posts: 151
    • View Profile
Re: Desktop Weather
« Reply #6 on: September 03, 2015, 08:55:24 am »
Quote
Anyone who feel like it can create a full set of nice icons (native OS/2 .ico files) can send them to me. ;)

Where do I get the original icons, or do you mean the ones in Weather.zip? PMView should convert them. Those icons don't seem to be used anyway (but that could be caused by the lack of bigicon support).
I used PMView and the OS/2 icon editor to create 3 or 4 icons that I included with weather.dll (contained within weather.zip) from the png files downloaded from the weather service you see when you use PNG Desktop.

Quote
The script use some services to try to locate you. The location is often based on the nearest station that your ISP allow that service to spot, so it may be your ISPs headquarters...
OpenWeather also need to have weather information for the area you live in.
It looks like the problem is with openweather. They only seem to know about major airports (although that doesn't explain why, or how, it chose Lethbridge (500 KM, small city, not listed) over Edmonton (25 KM Capital of Alberta, listed - the airport is about 50 KM from here, and it seems to be in a completely different weather area). The ISP is based in Vancouver (different province, on the other side of a couple of mountain ranges), but the Alberta branch is in Edmonton. Other weather services seem to be able to figure it out.

I also need to know what CityID is supposed to be. Currently, it says "(not_defined" with only one bracket. I would also like to know where that information is stored (I hope it is NOT in one of the system INI files - they grow too big without help).
You can specify CityID instead of the name as OpenWeather use that to identify the city.
It's a 12 character long string, thus the missing ")" in "(not defined)".
The information/data is stored as EA with the script file weather.cmd, clear that information and you can start over.

Quote
Ohh, make a copy of bigicons.txt and place it in the bigicons folder in case something happen... like you restart your computer and you have 1+ desktop widget.

I can find no bigicons.txt or bigicons folder, but that could be because I don't use bigicons. I do see a new icon added to the desktop at every program restart. The new icon is always in the upper left corner, partly off screen, which causes a scroll bar to appear (including when it updates, if I don't move it). If I accidentally click the scroll bar, it moves all of my icons to the right. It also always goes through the setup, even though the data is obviously stored somewhere.

Thanks...

The create icon function never tries to position the new object, so you'll have to move it by hand.

There should only be one icon on the desktop with the id "<wps_weather>". If you delete it, but not the program object in the startup folder that fetch the data you'll get a new desktop object at every desktop restart.
Delete "Update WEATHER" in the startup folder to get rid of the new desktop weather object.

//Jan-Erik

Doug Bissett

  • Hero Member
  • *****
  • Thank You
  • -Given: 1
  • -Receive: 38
  • Posts: 924
    • View Profile
Re: Desktop Weather
« Reply #7 on: September 03, 2015, 10:44:16 pm »
Quote
I used PMView and the OS/2 icon editor to create 3 or 4 icons that I included with weather.dll (contained within weather.zip) from the png files downloaded from the weather service you see when you use PNG Desktop.

Okay, I tried it on my test machine that has the PNG desktop support installed. It appears to be okay, but I still don't know where I can get the icons, to convert them to normal OS/2 icons. That should be a matter of opening the PNG in PMView, and save them as OS/2 icons, but where do I get the png files?.

Quote
You can specify CityID instead of the name as OpenWeather use that to identify the city.

But what is the City ID? Where would I find that? If I just type in "Edmonton", it finds Edmonton Australia. About as far away from here as you can get, without leaving the planet.

Quote
There should only be one icon on the desktop with the id "<wps_weather>". If you delete it, but not the program object in the startup folder that fetch the data you'll get a new desktop object at every desktop restart.
Delete "Update WEATHER" in the startup folder to get rid of the new desktop weather object.

??? This doesn't make sense. How do you start the program if it isn't in the startup folder? I didn't put it in the startup folder, but it seems to put itself back there if I don't immediately exit the setup, and the setup pops up every time I restart the system, demanding a new configuration, or at least an Exit. The old icon is still there.

I guess I just don't understand how this works, which makes it difficult to set it up. It also doesn't help that it isn't properly detecting my location (which could change, at every update, when I use my laptop for a trip).

Jan-Erik Lärka

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 11
  • Posts: 151
    • View Profile
Re: Desktop Weather
« Reply #8 on: September 04, 2015, 09:29:59 am »
Double click on the desktop object and the SmartGuide will open up.
Click next until you reach the tab "Symbols". Copy the link there to you web browser and add "http://" in front and "/01d.png" after. Replace "01d.png" with "01n.png" for the night version, "02d.png", "02n.png" etc. until 23, then jump to "50d.png" and "50n.png".

Visit http://openweathermap.org and type your city name "Edmonton", select the right place (if a list with many appear) and look for the address such as http://openweathermap.org/city/5946768 and the numbers at the end (5946768), that's OpenWeathers CityID.

The script create two program objects, one that will run the script and update the weather information and another on the desktop and look good :) and can show you the SmartGuide if you click on it so you shouldn't have the /// background obscuring the view.

Yes, it should detect the right location and that is also something that has to be corrected as the script contain links to more than one service to locate the position, but all seem to reply with slightly different JSon structures that I haven't figured out yet. Your tests and help is very much appreciated to help me find out what to change and adjust.

//Jan-Erik

ivan

  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 24
  • Posts: 627
    • View Profile
Re: Desktop Weather
« Reply #9 on: September 04, 2015, 03:45:13 pm »
Hi Jan-Erik,

I thought I would see how this works on a standard OS/2 machine.

I ran weather.cmd from a command window.  It downloaded some images and then placed an icon on the desktop (got00079.jpg) and left the command window static at 93% (got00080.jpg) and that is it.

There is no way that I can get anything that allows me to enter a city or any other information.

Doug Bissett

  • Hero Member
  • *****
  • Thank You
  • -Given: 1
  • -Receive: 38
  • Posts: 924
    • View Profile
Re: Desktop Weather
« Reply #10 on: September 04, 2015, 05:12:38 pm »
Quote
Visit http://openweathermap.org and type your city name "Edmonton", select the right place (if a list with many appear) and look for the address such as http://openweathermap.org/city/5946768 and the numbers at the end (5946768), that's OpenWeathers CityID.

Interesting. Going to http://openweathermap.org/ takes me directly to my home location (Sherwood Park, CA). I did have to search to find the CityID, which doesn't seem to be required.

Quote
Yes, it should detect the right location and that is also something that has to be corrected as the script contain links to more than one service to locate the position, but all seem to reply with slightly different JSon structures that I haven't figured out yet. Your tests and help is very much appreciated to help me find out what to change and adjust.

Okay, what can I do to help? It appears that going to the web site, using FF, takes me directly to the proper place, while your program takes me to the wrong place. How is that done? Perhaps I can spot the problem by doing it manually.

Quote
Double click on the desktop object and the SmartGuide will open up.
Click next until you reach the tab "Symbols". Copy the link there to you web browser and add "http://" in front and "/01d.png" after. Replace "01d.png" with "01n.png" for the night version, "02d.png", "02n.png" etc. until 23, then jump to "50d.png" and "50n.png".

HAH!, I found where the program put the .png files. They are in the root of the drive where I started the program from. That should make it easy to convert them to OS/2 icon files, but I would suggest that they should be in the folder where the program is, or in a sub folder, and not in the root. More later...

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 7
  • -Receive: 87
  • Posts: 1094
    • View Profile
Re: Desktop Weather
« Reply #11 on: September 04, 2015, 05:43:29 pm »
Openweather seems to work better for you (Doug and I have the same ISP). The cmd file thinks I'm in Campbell River which is a few hundred kilometers away on Vancouver Island and the web site thinks I'm in London GB.
I'm outside of Vancouver BC.

Doug Bissett

  • Hero Member
  • *****
  • Thank You
  • -Given: 1
  • -Receive: 38
  • Posts: 924
    • View Profile
Re: Desktop Weather
« Reply #12 on: September 04, 2015, 10:02:32 pm »
Quote
HAH!, I found where the program put the .png files. They are in the root of the drive where I started the program from. That should make it easy to convert them to OS/2 icon files, but I would suggest that they should be in the folder where the program is, or in a sub folder, and not in the root. More later...

Okay, I converted the PNG files to ICO files. PMView did it in a few seconds, but I had to tweak 4 of them with the icon editor (open, and save them). ZIP file added.

Now, if we can determine why the location is not working, this thing should work with, or without, the PNG desktop support.

I am suspicious that there is a list of locations, that gets downloaded, but there isn't enough room in the list for all of the locations.

Quote
(Doug and I have the same ISP).

That really isn't entirely true. Telus owns it, but the BC and Alberta internet access is run as two separate operations.

Jan-Erik Lärka

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 11
  • Posts: 151
    • View Profile
Re: Desktop Weather
« Reply #13 on: September 07, 2015, 01:26:09 pm »
Browser vs. script detection:
Our web browsers contain code that allow sites to detect the location in various ways while my script use rexx sockets that only give out the information provided by the script. Please open the script and look at the services hard coded there and try them in your browser and with wGet or cURL.

Pre eCS usage (Warp 4):
What happen when you double click on the desktop icon? I would guess that a command window flash by and then nothing. SmartGuide is included in eCS in a different location than in Warp 4, so that may be the reason. The script has to be adjusted to handle that as well in such case.

Non PNG Desktop:
Yes, it will download the files to the root as a last resort if there's no bigicons folder. Gues one could disable that part all together when there's no bigicons folder.

The script store information to:
I you have one desktop object it will save that to the EA of weather.cmd under weather...something, then next desktop object will be saved to the EA name in weather.cmd such as "newyork" in my example. It seem to overwrite that information if openweather can't detect the location right away.

Jan-Erik

ivan

  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 24
  • Posts: 627
    • View Profile
Re: Desktop Weather
« Reply #14 on: September 07, 2015, 03:51:07 pm »
Jan-Erik, that is exactly what I see, a blink of something trying to do something.

Now, where do I find the missing/misplaced SmartGuide that is needed?  Once I know where it is I can try some experiments on my next night shift.

One observation.  It might be an advantage if your script asked for some of this information at the beginning.