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 Sun 23 Nov 2014, 01:58
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 [9 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: 1455
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   1799 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: 1287
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  243 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: 1287
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: 11

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  313 Time(s) 
Back to top
View user's profile Send private message 
rokytnji


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

PostPosted: Fri 07 Mar 2014, 01:26    Post subject:  

Code:
h-4.1# inxi -wxx
Weather:   Conditions: 38 F (3 C) - Clear Wind: From the East at 4 MPH Humidity: 79%
           Pressure: 30.08 in (1018 mb) Time: March 6, 11:35 PM CST (America/Chicago)


http://www.murga-linux.com/puppy/viewtopic.php?t=53986

Code:
sh-4.1# su fido
sh-4.1$ inxi -Fxz
System:    Host: puppypc1974 Kernel: 3.10.5 i686 (32 bit, gcc: 4.7.1)
           Desktop: JWM git-835 Distro: Slacko Puppy Linux Linux 3.10.5 [ arch]
Machine:   System: Hewlett-Packard (portable) product: Presario CQ57 Notebook PC version: 068C110003204910000620100
           Mobo: Hewlett-Packard model: 3577 version: 24.48 Bios: Hewlett-Packard version: F.42 date: 11/07/2011
CPU:       Dual core AMD C-50 (-MCP-) cache: 1024 KB flags: (lm nx pae sse sse2 sse3 sse4a ssse3 svm) bmips: 3993.72
           Clock Speeds: 1: 1000.00 MHz 2: 1000.00 MHz
Graphics:  Card: ATI Device 9804 bus-ID: 00:01.0
           X.Org: 1.12.4 drivers: ati,radeon (unloaded: vesa) Resolution: 1366x768@60.0hz
           GLX Renderer: Gallium 0.4 on AMD PALM GLX Version: 2.1 Mesa 8.0.4 Direct Rendering: Yes
Audio:     Card: ATI SBx00 Azalia (Intel HDA) driver: snd_hda_intel bus-ID: 00:14.2 Sound: ALSA ver: k3.10.5
Network:   Card-1: Ralink Device 5390 driver: rt2800pci ver: 2.3.0 bus-ID: 07:00.0
           IF: wlan0 state: up speed: N/A duplex: N/A mac: <filter>
           Card-2: Realtek RTL8101E/RTL8102E PCI Express Fast Ethernet controller
           driver: r8169 ver: 2.3LK-NAPI port: 2000 bus-ID: 06:00.0
           IF: eth0 state: down mac: <filter>
Drives:    HDD Total Size: 250.1GB (1.2% used) 1: id: /dev/sda model: WDC_WD2500BEVT size: 250.1GB
Partition:
RAID:      No RAID devices detected - /proc/mdstat and md_mod kernel raid module present
Sensors:   System Temperatures: cpu: 62.5C mobo: N/A gpu: 63.0
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 89 Uptime: 2:13 Memory: 268.7/1623.6MB Runlevel: 5 Gcc sys: 4.7.1 Client: Shell (sh) inxi: 1.9.18
sh-4.1$


Code:
sh-4.1# inxi -help
inxi supports the following options. You can combine them, or list them
one by one: Examples: inxi -v4 -c6 OR inxi -bDc 6
 
If you start inxi with no arguments, it will show the short form.
The following options if used without -F, -b, or -v will show just option line(s):
A,C,D,G,I,M,N,P,R,S,f,i,n,o,p,l,u,r,s,t - you can use these alone or together to show
just the line(s) you want to see.
If you use them with -v [level], -b or -F, it will show the full output for that line
along with the output for the chosen verbosity level.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Output Control Options:
-A  Audio/sound card information.
-b  Basic output, short form. Like inxi -v 2, only minus hard disk names.
-c  Color schemes. Scheme number is required. Color selectors run a color selector option
    prior to inxi starting which lets you set the config file value for the selection.
    Supported color schemes: 0-32 Example: inxi -c 11
    Color selectors for each type display (NOTE: irc and global only show safe color set):
    94 - Console, out of X
    95 - Terminal, running in X - like xTerm
    96 - Gui IRC, running in X - like Xchat, Quassel, Konversation etc.
    97 - Console IRC running in X - like irssi in xTerm
    98 - Console IRC not in  X
    99 - Global - Overrides/removes all settings. Setting specific removes global.
-C  Full CPU output, including per CPU clockspeed (if available).
-d  Optical drive data. Same as -Dd. See also -x and -xx.
-D  Full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB. See also -x and -xx.
-f  All cpu flags, triggers -C. Not shown with -F to avoid spamming. ARM cpus show 'features'.
-F  Full output for inxi. Includes all Upper Case line letters, plus -s and -n.
    Does not show extra verbose options like -x -d -f -u -l -o -p -t -r
-G  Graphic card information (card, x type, resolution, glx renderer, version).
-i  Wan IP address, and shows local interfaces (requires ifconfig network tool). Same as -Nni
    Not shown with -F for user security reasons, you shouldn't paste your local/wan IP.
-I  Information: processes, uptime, memory, irc client (or shell type), inxi version.
-l  Partition labels. Default: short partition -P. For full -p output, use: -pl (or -plu).
-M  Machine data. Motherboard, Bios, and if present, System Builder (Like Lenovo).
    Older systems/kernels without the required /sys data can use dmidecode instead, run as root.
-n  Advanced Network card information. Same as -Nn. Shows interface, speed, mac id, state, etc.
-N  Network card information. With -x, shows PCI BusID, Port number.
-o  Unmounted partition information (includes UUID and LABEL if available).
    Shows file system type if you have file installed, if you are root OR if you have
    added to /etc/sudoers (sudo v. 1.7 or newer): <username> ALL = NOPASSWD: /usr/bin/file (sample)
-p  Full partition information (-P plus all other detected partitions).
-P  Basic partition information (shows what -v 4 would show, but without extra data).
    Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted partitions.
-r  Distro repository data. Supported repo types: APT; PACMAN; PISI; YUM; URPMQ; Ports.
-R  RAID data. Shows RAID devices, states, levels, and components, and extra data with -x/-xx
    md-raid: If device is resyncing, shows resync progress line as well.
-s  Sensors output (if sensors installed/configured): mobo/cpu/gpu temp; detected fan speeds.
    Gpu temp only for Fglrx/Nvidia drivers. Nvidia shows screen number for > 1 screens.
-S  System information: host name, kernel, desktop environment (if in X), distro
-t  Processes. Requires extra options: c (cpu) m (memory) cm (cpu+memory). If followed by numbers 1-20,
    shows that number of processes for each type (default: 5; if in irc, max: 5): -t cm10
    Make sure to have no space between letters and numbers (-t cm10 - right, -t cm 10 - wrong).
-u  Partition UUIDs. Default: short partition -P. For full -p output, use: -pu (or -plu).
-v  Script verbosity levels. Verbosity level number is required. Should not be used with -b or -F
    Supported levels: 0-7 Example: inxi -v 4
    0 - Short output, same as: inxi
    1 - Basic verbose, -S + basic CPU + -G + basic Disk + -I.
    2 - Networking card (-N), Machine (-M) data, shows basic hard disk data (names only),
        and, if present, basic raid (devices only, and if inactive, notes that). similar to: inxi -b
    3 - Advanced CPU (-C), network (-n) data, and switches on -x advanced data option.
    4 - Partition size/filled data (-P) for (if present):/, /home, /var/, /boot
        Shows full disk data (-D).
    5 - Audio card (-A); sensors (-s), partition label (-l) and UUID (-u), short form of optical drives,
        standard raid data (-R).
    6 - Full partition (-p), unmounted partition (-o), optical drive (-d), full raid; triggers -xx.
    7 - Network IP data (-i); triggers -xxx.
-w  Local weather data/time. To check an alternate location, see: -W <location>.
    For extra weather data options see -x, -xx, and -xxx.
-W  <location> - <location> supported options: postal code; city,[state/country]; latitude,longitude
    Only use if you want the weather somewhere other than the machine running inxi.
    Use only ascii characters, replace spaces in city/state/country names with +: new+york,ny
-x  Adds the following extra data (only works with verbose or line output, not short form):
    -C - Bogomips on Cpu;
    -d - Extra optical drive data; adds rev version to optical drive.
    -D - Hdd temp with disk data if you have hddtemp installed, if you are root OR if you have added to
         /etc/sudoers (sudo v. 1.7 or newer): <username> ALL = NOPASSWD: /usr/sbin/hddtemp (sample)
    -G - Direct rendering status for Graphics (in X).
    -G - (for single gpu, nvidia driver) screen number gpu is running on.
    -i - IPv6 as well for LAN interface (IF) devices.
    -I - System GCC, default. With -xx, also show other installed GCC versions.
         If running in console, not in IRC client, shows shell version number,
         if detected. Adds current runlevel.
    -N -A - Version/port(s)/driver version (if available) for Network/Audio;
    -N -A -G - Network, audio, graphics, shows PCI Bus ID/Usb ID number of card;
    -R - md-raid: Shows component raid id. Adds second RAID Info line: raid level; report on drives (like 5/5);
         blocks; chunk size; bitmap (if present). Resync line, shows blocks synced/total blocks.
       - zfs-raid: Shows raid array full size; available size; portion allocated to RAID
    -S - Desktop toolkit if avaliable (GNOME/XFCE/KDE only); Kernel gcc version
    -t - Memory use output to cpu (-xt c), and cpu use to memory (-xt m).
    -w/-W - Wind speed and time zone (-w only).
-xx Show extra, extra data (only works with verbose or line output, not short form):
    -A - Chip vendor:product ID for each audio device.
    -D - Disk serial number.
    -G - Chip vendor:product ID for each video card.
    -I - Other detected installed gcc versions (if present). System default runlevel.
         Adds parent program (or tty) for shell info if not in IRC (like Konsole or Gterm).
    -M - Chassis information, bios rom size (dmidecode only), if data for either is available.
    -N - Chip vendor:product ID for each nic.
    -R - md-raid: Superblock (if present); algorythm, U data. Adds system info line
         (kernel support,read ahead, raid events). If present, adds unused device line.
         Resync line, shows progress bar.
    -S - Display manager (dm) in desktop output, if in X (like kdm, gdm3, lightdm).
    -w/-W - Humidity, barometric pressure.
    -xx -@ <11-14> - Automatically uploads debugger data tar.gz file to ftp.techpatterns.com.
-xxx Show extra, extra, extra data (only works with verbose or line output, not short form):
    -S - Panel/shell information in desktop output, if in X (like gnome-shell, cinnamon, mate-panel).
    -w/-W - Location (uses -z/irc filter), weather observation time, wind chill, heat index,
         dew point (shows extra lines for data where relevant).
-z  Security filters for IP/Mac addresses, location, user home directory name. Default on for irc clients.
-Z  Absolute override for output filters. Useful for debugging networking issues in irc for example.
 
Additional Options:
-h --help      This help menu.
-H             This help menu, plus developer options. Do not use dev options in normal operation!
--recommends   Checks inxi application dependencies + recommends, and directories, then shows
               what package(s) you need to install to add support for that feature.
-U             Auto-update script. Will also install/update man page. Note: if you installed as root, you
               must be root to update, otherwise user is fine. Man page installs require root user mode.
-V --version   inxi version information. Prints information then exits.
 
Debugging Options:
-%  Overrides defective or corrupted data.
-@  Triggers debugger output. Requires debugging level 1-14 (8-10 - logging of data).
    Less than 8 just triggers inxi debugger output on screen.
    1-7  - On screen debugger output
    8    - Basic logging
    9    - Full file/sys info logging
    10   - Color logging.
    The following create a tar.gz file of system data, plus collecting the inxi output to file:
    To automatically upload debugger data tar.gz file to ftp.techpatterns.com: inxi -xx@ <11-14>
    For alternate ftp upload locations: Example: inxi -! ftp.yourserver.com/incoming -xx@ 14
    11 - With data file of xiin read of /sys.
    12 - With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc.
    13 - With data from dev, disks, partitions, etc., plus xiin data file.
    14 - Everything, full data collection.
Advanced Options:
-! 31  Turns off hostname in output. Useful if showing output from servers etc.
-! 32  Turns on hostname in output. Overrides global B_SHOW_HOST='false'
 
sh-4.1#
n

Can be installed in any Puppy version. I ran it as Fido so it would supply glx info for Graphics. It will run as root but will message "n/a for graphics as root".

Not a complicated install either

http://code.google.com/p/inxi/wiki/Installation
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 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.1386s ][ Queries: 12 (0.0060s) ][ GZIP on ]