simple icon tray

Window managers, icon programs, widgets, etc.
Post Reply
Message
Author
User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#91 Post 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.
Attachments
capture29320.png
(9.37 KiB) Downloaded 1530 times
capture29633.png
(32.38 KiB) Downloaded 1569 times
Puppy Linux Blog - contact me for access

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#92 Post 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

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#93 Post 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.
Puppy Linux Blog - contact me for access

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#94 Post 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"
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

tweather

#95 Post 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

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#96 Post 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
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#97 Post 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.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#98 Post 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

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#99 Post 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.
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Yweather 0.1a - taskbar weather app

#100 Post 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

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#101 Post 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

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#102 Post 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.
Attachments
sit-master.tar.gz
(3.89 KiB) Downloaded 639 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#103 Post by vovchik »

Dear technosaurus,

Very nice. I like the addition of markup.

With kind regards,
vovchik

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#104 Post 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

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#105 Post 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
Attachments
sit-master-james.patch.gz
(1.43 KiB) Downloaded 608 times
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#106 Post 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)

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#107 Post 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).
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#108 Post 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
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#109 Post 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
Attachments
sit-james-master-bin.tar
James patch to technosaurus sit-master
(20 KiB) Downloaded 783 times

eadmaster
Posts: 46
Joined: Sat 09 Feb 2013, 11:34
Contact:

#110 Post 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...

Post Reply