Page 5 of 9

Posted: Tue 01 Jan 2013, 03:17
by 01micko
Hello vovchik

To get your weather code (replace zipcode variable) you have to jump through some hoops. You go to the download page for accuweather and get the "Net Weather" as if you were to add it to your website. Agree to their terms and a code box is presented. Scroll to the zipcode part and there is your weather code, replace spaces with %20. Mine is:

Code: Select all

zipcode='OCN|AU|QLD|GOLD%20COAST|&metric=1'
as it appears in /usr/share/sit/functions, works but is in farenheit. Would likely need to parse the METRIC= option in seaside's script for a choice. Or do the math, either way.
EDIT: no need for math or extra code, just add the "&metric=1" bit further down in the code for celcius.. edited my code and it works. For farenheit, no param or metric=0.

Posted: Tue 01 Jan 2013, 10:29
by vovchik
Dear 01micko,

Happy New Year! You solved the problen in a very clever way. No need to register, but almost, to see the address. I also now get Celcius, which is what I want. Thanks.

With kind regards,
vovchik

Posted: Tue 01 Jan 2013, 11:44
by 01micko
Hello vovchik

Yes, it is the same weather code as Pwidgets uses, but I didn't know you could append the "metric=" bit to that code, a handy feature.

Once upon a time Accuweather had that code in the URL for a location, but now it is hidden away in the html. I just stumbled upon the "Net Weather" method, kind of an "educated guess". Easy enough I think :) .

Happy New Year to you too.

Posted: Tue 01 Jan 2013, 14:06
by Geoffrey
I had a bit of a play with this weather app, I managed to get it working using yad for the notification.

Code: Select all

#! /bin/bash

function refresh() {
	zipcode='10012' # <<< put zipcode here
	
	loc='http://rss.accuweather.com/rss/liveweather_rss.asp?locCode='"$zipcode"''
	wget -O /tmp/tweather $loc
	
	w=`xml-printf '%s\n' /tmp/tweather :/rss/channel/item/description`
	
	i=o
	while read line; do  
	  array[$((++i))]=$line
	  case $i in
		1) CURRENT=${line%%<*} CURRENTI=${line#*=} CURRENTI=${CURRENTI/>/} ; wget -O /tmp/currenti ${CURRENTI//\"/}  ;;
		2) RANGE=${line%%<*}       ;;
		3) TOMORROW=${line%%<*}    ;;
		*)                         ;;
	  esac	
	done <<<"$w"
echo "$CURRENT 
    $RANGE
-------------------------------------------------------------------
Tomorrow: $TOMORROW" >/tmp/tweather-tip
}
export -f refresh
sh -c refresh

line1=`awk 'NR==1' < /tmp/tweather-tip`	
line2=`awk 'NR==2' < /tmp/tweather-tip`
line3=`awk 'NR==3' < /tmp/tweather-tip`
line4=`awk 'NR==4' < /tmp/tweather-tip`

exec yad --notification --text="$line1 $line2 $line3 $line4" --image="/tmp/currenti" --command "sh -c refresh"

tweather

Posted: Tue 01 Jan 2013, 17:04
by seaside
01micko,

I was pleased to see that you found a world solution for Accuweather because I just took a look at Yahoo weather and while they have the same xml path to the "description" tag, the actual content is composed of DATA html markup. Short of stripping out the html code, I'm not sure how sit can display any markup.

Geoffrey,

Yes, nice and Yad is always a good swiss army knife located comfortably between Xdialog and gtkdialog.

vovchik ,

I feel much warmer knowing that you'll be able to tell exactly how cold it is where you are. :D

A very Happy New Year to all,
s

Posted: Tue 01 Jan 2013, 23:11
by technosaurus
to get markup from rss feeds most people typically grep for the needed tag and then strip the tags out using sed ... I use shell only methods such as:
(just the jist of it - not tested, and I always seem to mix up ## and %%)

Code: Select all

wget -O - url | while read LINE; do
case "$LINE in" *something*)
  CONTENT=${LINE%%* beginning stuff to remove>}
  CONTENT=${CONTENT##</end stuff to remove*}
  echo $CONTENT >>somefile.svg
;;
esac
done

Posted: Fri 04 Jan 2013, 07:54
by mavrothal
seaside wrote: As the latest sit by default looks for functions in /usr/share/sit/functions, the above script will not refresh. So I moved the refresh function to /usr/share/sit/function*refresh. I also combined sit 1.0, xml-printf (your nicely reduced one) and tweather into an all inclusive pet as attached.
Works nicely with JWM tray and also with tint2 that I tried it.
I have this little /root/Startup script (since is will fail with no connection in pace).

Code: Select all

#!/bin/sh

IFCONFIG="`ifconfig | grep '^[pwe]' | grep -v 'wmaster'`"
while [ "$IFCONFIG" != "" ]; do
	sleep 1
    ping -c 1 8.8.8.8 
    if [ $? -eq 0 ];then
		break
	else
		ping -c 1 www.google.com
		if [ $? -eq 0 ];then
			break
		fi
	fi
done

tweather
One "problem" I have is that right-click on the applet will quit it.
How do I avoid this?

Happy New Year.

Posted: Fri 04 Jan 2013, 17:25
by seaside
mavrothal wrote:
One "problem" I have is that right-click on the applet will quit it.
How do I avoid this?

Happy New Year.
mavrothal,

Happy New Year to you as well.

You can change this line-

Code: Select all

sit /tmp/currenti /tmp/tweather-tip refresh  "kill $( </tmp/tweatherpid)" & 
to

Code: Select all

sit /tmp/currenti /tmp/tweather-tip refresh  & 
That should reassign the right-click to no action.

Nice script for checking if your connection is up.

Regards,
s

Posted: Fri 04 Jan 2013, 23:41
by Geoffrey
mavrothal wrote:
I have this little /root/Startup script (since is will fail with no connection in pace).

Code: Select all

#!/bin/sh

IFCONFIG="`ifconfig | grep '^[pwe]' | grep -v 'wmaster'`"
while [ "$IFCONFIG" != "" ]; do
	sleep 1
    ping -c 1 8.8.8.8 
    if [ $? -eq 0 ];then
		break
	else
		ping -c 1 www.google.com
		if [ $? -eq 0 ];then
			break
		fi
	fi
done

tweather
Nice, I was only the other day looking for such a script, I found that cairo-dock with it's weather widget has the same dilemma, I will be using this, thanks.

Yweather 0.1a - taskbar weather app

Posted: Mon 07 Jan 2013, 14:17
by vovchik
Dear guys,

I have coded a taskbar weather app in BaCon - based on Yahoo's weather API - and it is available here: http://www.murga-linux.com/puppy/viewto ... 079#676079.

Have fun....

With kind regards,
vovchik

Posted: Mon 07 Jan 2013, 16:40
by seaside
technosaurus,

I noticed that Vovchik's Yweather application uses markup in the icon tooltip.

Is it possible for "sit" to do this as well? :?:

Regards,
s

Posted: Tue 08 Jan 2013, 17:00
by technosaurus
you can now,... http://developer.gnome.org/pango/stable ... ormat.html

(just had to change *tooltip_text to *tooltip_markup ... unformatted text still works too, though I didn't check new lines)

I have included the current master branch which should build on Linux, BSD, Mac and Win32/64

the win32 version has lots of downloads but no comments, if anyone is using it let me know its shortcomings so I can improve its cross platform abilities (for example what would be a good path for includefiles? C:\\MinGW...) ... same goes for Mac if anyone has built it... so I can put out another point release.

Posted: Tue 08 Jan 2013, 17:11
by vovchik
Dear technosaurus,

Very nice. I like the addition of markup.

With kind regards,
vovchik

Posted: Tue 08 Jan 2013, 21:40
by seaside
technosaurus,

You have done it again. Works nicely indeed, thank you.

New lines seem to work just fine.

I really think sit should be part of Puppy, as it is versatile, small, and so easily implements an attractive interface.

Best Regards,
s

Posted: Thu 24 Jan 2013, 02:05
by jamesbond
Patch:
1. Remove default include files path (if this path doesn't exist, execution fails - bad)
2. change popen mode from "r" to "w" - otherwise no output
3. ensure pclose after popen so that we don't get zombie process
4. close pid from g_spawn_async
5 add version numbering so we know which version of sit this is.
6. modify build process so that it is 64-bit compatible (should still work on 32-bit)
7. modify build process so that it tests correctly

Posted: Sun 27 Jan 2013, 01:28
by seaside
jamesbond wrote:Patch:
1. Remove default include files path (if this path doesn't exist, execution fails - bad)
2. change popen mode from "r" to "w" - otherwise no output
3. ensure pclose after popen so that we don't get zombie process
4. close pid from g_spawn_async
5 add version numbering so we know which version of sit this is.
6. modify build process so that it is 64-bit compatible (should still work on 32-bit)
7. modify build process so that it tests correctly
jamesbond,

Thank you for the improvements.
The original sit-master binary compiled by technosaurus runs in Puppy precise 5.4.1 and this one failed after patching.....

Code: Select all

 ./build
/usr/bin/ld: /tmp/cckw5xNo.o: undefined reference to symbol 'g_file_monitor_file'
/usr/bin/ld: note: 'g_file_monitor_file' is defined in DSO /usr/lib/libgio-2.0.so.0 so try adding it to the linker command line
/usr/lib/libgio-2.0.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
I added the link to -L/usr/lib/libgio-2.0.so.0 on the command line and that didn't make any difference.

I think it would be great to have this generally in Puppy and ideally one version for all, but I don't know enough about compiling.

Regards,
s
(EDIT: I just tried to compile the master-sit original and got the same error, so something must be different in Puppy Precise 5.4.1, even though the binary included works)

Posted: Sat 02 Feb 2013, 11:45
by jamesbond
I agree.

This is how to fix the compile it recent puppies (tested in my homebrew slackware-based 32-bit puplet). Do it after you apply the patch.

Change line 7 in "build" from

Code: Select all

sit.c -o sit -lgtk-x11-2.0 && strip --strip-all -R .note -R .comment sit
To

Code: Select all

sit.c -o sit -lgtk-x11-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 && strip --strip-all -R .note -R .comment sit
Note the addition of -lgio-2.0 -lgobject-2.0 -lglib-2.0.

The easier way to compile without having to remember all this thingamagic is

Code: Select all

sit.c -o sit $(pkg-config --libs gtk+-2.0) && strip --strip-all -R .note -R .comment sit
but technosaurus will disapprove of it :lol: (because, although it does make it easier to compile, it causes the compile to pull in unnecessary dependencies and make it slightly larger).

Posted: Sat 02 Feb 2013, 14:45
by technosaurus
I think I was adding the -Wl,--as-needed flag too, which tells the linker to look in the deps. Amazingly it builds and runs fine on windows, so I would guess its the hacky canonical patches. I cant' check the puppy build right now since my classes all require windows and/or a full java sdk.

-btw thanks for the patches

Posted: Mon 04 Feb 2013, 17:46
by seaside
jamesbond wrote:
Change line 7 in "build" from

Code: Select all

sit.c -o sit -lgtk-x11-2.0 && strip --strip-all -R .note -R .comment sit
To

Code: Select all

sit.c -o sit -lgtk-x11-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 && strip --strip-all -R .note -R .comment sit
Note the addition of -lgio-2.0 -lgobject-2.0 -lglib-2.0.
jamesbond,

Thanks. It worked nicely.

In case anyone wants the compiled binary made in Precise 5.4.3, I've attached it here.

Regards,
s

Posted: Sun 14 Apr 2013, 11:32
by eadmaster
is it possible to set the tooltip as a command instead of a fixed string?
So when the mouse is hovering, the cmd is executed and the output is displayed in the tooltip...