Active Topics

 



Notices


Reply
Thread Tools
No!No!No!Yes!'s Avatar
Posts: 700 | Thanked: 846 times | Joined on Nov 2009
#1
Customize Queen BeeCon Widget (>=v0.1.4) to display:
Random images from Flickr's 'Most Interesting' pages

The Beecon will display random photos/images from http://m.flickr.com. Change update policies as per your taste.





WARNING!!! wget package must be installed!

Updates on click or every 30mins. See if you like it!!!

Import this as per HERE
Code:
[queen-beecon-header]
version=1,000000
checksum=1478530
[queen-beecon-exported-instance]
widgetType=1
widgetVisible=1
operationalStatus=0
hideCanvas=true
snippetBgRGB=0
beecon_lt0_ImgZoom=0
beecon_lt0_BgRGB=2
beecon_lt0_ImgFilename=queen-beecon-syserr.png
beecon_eq0_ImgZoom=12
beecon_eq0_BgRGB=3
beecon_eq0_ImgFilename=queen-beecon-appok.png
beecon_eq1_ImgZoom=0
beecon_eq1_BgRGB=4
beecon_eq1_ImgFilename=queen-beecon-appwrn.png
beecon_ge2_ImgZoom=0
beecon_ge2_BgRGB=5
beecon_ge2_ImgFilename=queen-beecon-apperr.png
beecon_idxge2_ImgZoom=0
beecon_idxge2_BgRGB=11
beecon_idxge2_ImgFilename=queen-beecon-index.png
widWidth=302
widHeight=205
instanceTitle=flickr
instanceCmd=wget -t 1 -T 5 -q -U "Mozilla/5.0 (X11; U; Linux armv7l; en-US; rv:1.9.2a1pre) Gecko/20091127 Firefox/3.5 Maemo Browser 1.5.6 RX-51 N900" -O - "http://m.flickr.com"|awk 'BEGIN{FS="[\\"]+"}/<img src=.+alt="">/{r=system("wget -t 1 -T 5 -q -O /tmp/qbwflickr0.jpg \\""$2"\\"");}END{exit r}'
cmdImgFilename=queen-beecon.png
cmdImgZoom=0
cmdFgRGB=1
cmdVisibilityPosition=0
cmdImgVisibilityPosition=0
cmdJustify=0
cmdFontName=3
cmdFontSize=12
resImgFilename=/tmp/qbwflickr0.jpg
resImgZoom=13
resFgRGB=1
resVisibilityPosition=0
resImgVisibilityPosition=5
resJustify=0
resFontName=2
resFontSize=12
updOnStartup=false
updOnClick=true
updOnDesktop=false
delayIndex=4
updNeworkPolicy=0
P.S. for those of you wondering about QBW Naive Dice Poker ... it's working like charm with new 0.1.7 DBUS features
__________________
Have a look at Queen BeeCon Widget (WIKI) Customizable and flexible widget-based multi-instance monitoring, alerting and interactive tool for the N900
Please provide comments and feedback for having QBW supported and enhanced further - (DONATE) - v1.3.3devel / v1.3.3testing / v1.3.3extras
 

The Following 3 Users Say Thank You to No!No!No!Yes! For This Useful Post:
No!No!No!Yes!'s Avatar
Posts: 700 | Thanked: 846 times | Joined on Nov 2009
#2
ok ... this beecon here will fetch a random image from page:

http://m.flickr.com/explore/interesting/



Code:
[queen-beecon-header]
version=1,000000
checksum=1904336
[queen-beecon-exported-instance]
widgetType=1
widgetVisible=1
operationalStatus=0
hideCanvas=true
snippetBgRGB=0
beecon_lt0_ImgZoom=0
beecon_lt0_BgRGB=2
beecon_lt0_ImgFilename=queen-beecon-syserr.png
beecon_eq0_ImgZoom=12
beecon_eq0_BgRGB=3
beecon_eq0_ImgFilename=queen-beecon-appok.png
beecon_eq1_ImgZoom=0
beecon_eq1_BgRGB=4
beecon_eq1_ImgFilename=queen-beecon-appwrn.png
beecon_ge2_ImgZoom=0
beecon_ge2_BgRGB=5
beecon_ge2_ImgFilename=queen-beecon-apperr.png
beecon_idxge2_ImgZoom=0
beecon_idxge2_BgRGB=11
beecon_idxge2_ImgFilename=queen-beecon-index.png
widWidth=349
widHeight=271
instanceTitle=flickr
instanceCmd=a=`dd if=/dev/urandom bs=1 count=1 | od -i | head -n 1 | cut -f2- -d' '`;x=`expr $a % 24`;wget -t 1 -T 5 -q -U "Mozilla/5.0 (X11; U; Linux armv7l; en-US; rv:1.9.2a1pre) Gecko/20091127 Firefox/3.5 Maemo Browser 1.5.6 RX-51 N900" -O - "http://m.flickr.com/explore/interesting/"|awk -v i=$x 'BEGIN{FS="[\\"]+";n=0}/<img src=.+class="pc_img">/{gsub(/_s\\.jpg/,"_m.jpg",$4);s[n]=$4;n++;}END{r=system("wget -t 1 -T 5 -q -O /tmp/qbwflickr0.jpg \\""s[i]"\\"");exit r;}'
cmdImgFilename=queen-beecon.png
cmdImgZoom=0
cmdFgRGB=1
cmdVisibilityPosition=0
cmdImgVisibilityPosition=0
cmdJustify=0
cmdFontName=3
cmdFontSize=12
resImgFilename=/tmp/qbwflickr0.jpg
resImgZoom=1
resFgRGB=1
resVisibilityPosition=0
resImgVisibilityPosition=5
resJustify=0
resFontName=2
resFontSize=12
updOnStartup=false
updOnClick=true
updOnDesktop=false
delayIndex=4
updNeworkPolicy=0
__________________
Have a look at Queen BeeCon Widget (WIKI) Customizable and flexible widget-based multi-instance monitoring, alerting and interactive tool for the N900
Please provide comments and feedback for having QBW supported and enhanced further - (DONATE) - v1.3.3devel / v1.3.3testing / v1.3.3extras
 

The Following User Says Thank You to No!No!No!Yes! For This Useful Post:
Posts: 1,463 | Thanked: 1,916 times | Joined on Feb 2008 @ Edmonton, AB
#3
Code:
apt-get install wget
wasn't obvious to me, i'm a linux n00b :P
 
No!No!No!Yes!'s Avatar
Posts: 700 | Thanked: 846 times | Joined on Nov 2009
#4
Here's an advanced version of the Queen Beecon Flickr Widget which takes advantage of several of new features in versions >=0.1.9.x

In particular:
  1. The capability of QBW to sense the position where the widget has been clicked in the 3x3 grid on its surface
  2. The parameter substitution $QBW_HOTSPOT_PRESS
  3. The parameter substitution $QBW_CURRENT_RESULTS_TEXT



More specifically:
  • When the Flickr Widget gets loaded, on phone startup, it just updates itself by fetching a random image
  • Every time the desktop, where the Flickr Widget is on, gets active, the widget just updates itself by fetching a random image
  • Every 30 minutes the Flickr Widget just updates itself by fetching a random image
  • When the Flickr Widget is clicked in sector idx=9 it opens the browser and fetches the specific page where the image is located thus allowing to experience more details about it


Here's the Beecon Exported Instance Data:
Code:
[queen-beecon-header]
version=1,000000
checksum=4422022
[queen-beecon-exported-instance]
widgetType=0
widgetVisible=1
operationalStatus=0
hideCanvas=true
snippetBgRGB=0
snippetExtBgRGB=#ffffffffffff
beecon_lt0_ImgZoom=0
beecon_lt0_BgRGB=2
beecon_lt0_ExtBgRGB=#808080808080
beecon_lt0_ImgFilename=queen-beecon-syserr.png
beecon_eq0_ImgZoom=1
beecon_eq0_BgRGB=3
beecon_eq0_ExtBgRGB=#0000ffff0000
beecon_eq0_ImgFilename=/tmp/qbwflickr0.jpg
beecon_eq1_ImgZoom=0
beecon_eq1_BgRGB=4
beecon_eq1_ExtBgRGB=#ffffffff0000
beecon_eq1_ImgFilename=-queen-beecon-appwrn.png
beecon_ge2_ImgZoom=0
beecon_ge2_BgRGB=5
beecon_ge2_ExtBgRGB=#ffff00000000
beecon_ge2_ImgFilename=queen-beecon-apperr.png
beecon_idxge2_ImgZoom=0
beecon_idxge2_BgRGB=11
beecon_idxge2_ExtBgRGB=#0000ffffffff
beecon_idxge2_ImgFilename=queen-beecon-index.png
widWidth=490
widHeight=330
instanceTitle=FlickrImages
instanceCmd=if [ "_$QBW_HOTSPOT_PRESS" == "_9" ] ; then run-standalone.sh dbus-send --system --print-reply --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"$QBW_CURRENT_RESULTS_TEXT"; else a=`dd if=/dev/urandom bs=1 count=1 | od -i | head -n 1 | cut -f2- -d' '`;x=`expr $a % 24`;wget -t 1 -T 10 -q -U "Mozilla/5.0 (X11; U; Linux armv7l; en-US; rv:1.9.2a1pre) Gecko/20091127 Firefox/3.5 Maemo Browser 1.5.6 RX-51 N900" -O - "http://m.flickr.com/explore/interesting/"|awk -v i=$x 'BEGIN{FS="[\\"]+";n=0}/^\\t\\t<a href=.+>/{u[n]=$2;}/<img src=.+class="pc_img">/{gsub(/_s\\.jpg/,"_m.jpg",$4);s[n]=$4;n++;}END{r=system("wget -t 1 -T 5 -q -O /tmp/qbwflickr0.jpg \\""s[i]"\\"");print "http://m.flickr.com"u[i];exit r;}';fi
cmdImgFilename=queen-beecon.png
cmdImgZoom=0
cmdFgRGB=1
cmdExtFgRGB=#ffffffffffff
cmdTextAngle=0
cmdVisibilityPosition=0
cmdImgVisibilityPosition=0
cmdJustify=0
cmdExtFont=Nokia Sans Italic Bold 12
cmdFontName=3
cmdFontSize=12
resImgFilename=;/tmp/qbwflickr0.jpg
resImgZoom=1
resFgRGB=1
resExtFgRGB=#ffffffffffff
resTextAngle=0
resVisibilityPosition=0
resImgVisibilityPosition=5
resJustify=0
resExtFont=Nokia Sans Bold 12
resFontName=2
resFontSize=12
updOnStartup=true
updOnClick=true
updOnDesktop=true
delayIndex=4
customIntervalSecs=10
updNeworkPolicy=1
updOnDBUS=0
updOnDBUSBus=0
updOnDBUSMatchRule=
rememberMe=
Let's focus on the script in a much readable format:
Code:
if [ "_$QBW_HOTSPOT_PRESS" == "_9" ] ; then
$QBW_HOTSPOT_PRESS variable gets substituted at run-time with the index of the position where the widget was clicked
Code:
	run-standalone.sh dbus-send
		--system 
		--print-reply 
		--type=method_call 
		--dest=com.nokia.osso_browser 
		/com/nokia/osso_browser/request 
		com.nokia.osso_browser.load_url
In this case we just issue the dbus command which spawn the browser and loads the URL specified by next parameter
Code:
		string:"$QBW_CURRENT_RESULTS_TEXT";
$QBW_CURRENT_RESULTS_TEXT variable gets substituted at run-time with the content of the results text of the widget itself (which in this case is hidden but still present) that contains the url of the image details page
Code:
else
If the widget update occurred due to other update policies (startup, timer, click on sectors other then 9, desktop switch...)
Code:
	a=`dd if=/dev/urandom bs=1 count=1 | od -i | head -n 1 | cut -f2- -d' '`;x=`expr $a % 24`;
We compute a random value between 0 and 24
Code:
	wget 
		-t 1 
		-T 10 
		-q 
		-U "Mozilla/5.0 (X11; U; Linux armv7l; en-US; rv:1.9.2a1pre) Gecko/20091127 Firefox/3.5 Maemo Browser 1.5.6 RX-51 N900" 
		-O - 
		"http://m.flickr.com/explore/interesting/"
We try once (-t 1), with a timeout of 10 seconds (-T 10), very silently (-q), setting our identity as if we were MicroB browser to retreive the lightest possible page (-U "Mozilla/5.0 (X11; U; Linux armv7l; en-US; rv:1.9.2a1pre) Gecko/20091127 Firefox/3.5 Maemo Browser 1.5.6 RX-51 N900"), sending the "http://m.flickr.com/explore/interesting/" page source to standard out (-O -) ready to be piped to next command
Code:
	| awk 
		-v i=$x
awk will take care of parsing our page, variable "i", in our awk script, will hold the random number we generated a bit earlier
Code:
			'BEGIN {
				FS="[\"]+"
				;n=0
			}
Beginning part of awk script will set the field separator to ' " ' character and initialize our counter "n"
Code:
			/^\t\t<a href=.+>/ { 
				u[n]=$2;
			}
We will then iterate through all pictures and retrieve the details page URL which we store in array u[]
Code:
			/<img src=.+class="pc_img">/ {
				gsub(/_s\.jpg/,"_m.jpg",$4);
				s[n]=$4;
				n++;
			}
We will then iterate through images, adjust URL for a more suitable image size (medium), store image URL in array s[] and increment our counter for next URL/image tuple
Code:
			END {
				r=system("wget -t 1 -T 5 -q -O /tmp/qbwflickr0.jpg \""s[i]"\"");
				print "http://m.flickr.com"u[i];
				exit r;
			}';
After having parsed all URLs/images tuples in our html source, we will then spawn the last image fetch with URL from random position in array s[] and save it to /tmp/qbwflickr0.jpg file which we will display if wget succeeds and return 0 exit status.
We then construct and print the URL of the image details page in array u[] and print it to our widget (Remember that it will not be shown on the widget because Results text is set as hidden)
This URL will be fetched, if necessary, next time sector 9 is clicked to open image details page URL.
Code:
fi
And we are done now!!!
__________________
Have a look at Queen BeeCon Widget (WIKI) Customizable and flexible widget-based multi-instance monitoring, alerting and interactive tool for the N900
Please provide comments and feedback for having QBW supported and enhanced further - (DONATE) - v1.3.3devel / v1.3.3testing / v1.3.3extras
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 04:07.