@@ -225,6 +225,7 @@ setWallpaper() {
225
225
if [[ -n " $random_image " ]]; then
226
226
setImage " $random_image " &
227
227
fi
228
+ osdNotify " $specific "
228
229
return
229
230
fi
230
231
@@ -249,10 +250,8 @@ setWallpaper() {
249
250
fi
250
251
fi
251
252
fi
252
-
253
- if [ " $OSD " == " TRUE" ]; then
254
- osdNotify " $specific "
255
- fi
253
+
254
+ osdNotify " $specific "
256
255
}
257
256
258
257
# set the Wallpaper
@@ -393,15 +392,17 @@ contains() {
393
392
# send onscreen-notfication if weather changed
394
393
# $1: message, new weather-state
395
394
osdNotify () {
396
- if [[ -z " $last_state " ]] || [ " $last_state " != " $1 " ]; then
397
- if command -v notify-send > /dev/null; then
398
- notify-send " izulu" " $( gettext " $1 " ) "
399
- else
400
- echo " notify-send not installed, but osd via -o requested." \
401
- " Install libnotify-bin to use the osd."
395
+ if [ " $OSD " == " TRUE" ]; then
396
+ if [[ -z " $last_state " ]] || [ " $last_state " != " $1 " ]; then
397
+ if command -v notify-send > /dev/null; then
398
+ notify-send " izulu" " $( gettext " $1 " ) "
399
+ else
400
+ echo " notify-send not installed, but osd via -o requested." \
401
+ " Install libnotify-bin to use the osd."
402
+ fi
402
403
fi
404
+ last_state=" $1 "
403
405
fi
404
- last_state=" $1 "
405
406
}
406
407
407
408
# choose randomly a wallpaper
@@ -431,8 +432,13 @@ cycleWallpaper() {
431
432
esac
432
433
433
434
if [[ -z " $randomdir " ]]; then
434
- setWallpaper " $specific " " $generic " " TRUE"
435
- return 1
435
+ flickrimg=$( getFlickrImage " $generic " )
436
+ if [[ -z " $flickrimg " ]]; then
437
+ setWallpaper " $specific " " $generic " " TRUE"
438
+ return 1
439
+ else
440
+ echo " $flickrimg "
441
+ fi
436
442
fi
437
443
438
444
@@ -446,6 +452,51 @@ cycleWallpaper() {
446
452
echo " ${pictures[$chosen]} "
447
453
}
448
454
455
+ getFlickrImage () {
456
+ local generic=" $1 "
457
+ # flickriver sorts the flickr groups images randomly for us
458
+ local riverurl=" "
459
+ case " $generic " in
460
+ " gen_sun" )
461
+ riverurl=" http://www.flickriver.com/groups/982364@N21/pool/random/"
462
+ ;;
463
+ " gen_cloud" )
464
+ riverurl=" http://www.flickriver.com/groups/clouds-mildness/pool/random/"
465
+ ;;
466
+ " gen_rain" )
467
+ riverurl=" http://www.flickriver.com/groups/387174@N22/pool/random/"
468
+ ;;
469
+ " gen_snow" )
470
+ riverurl=" http://www.flickriver.com/groups/snow_pictures/pool/random/"
471
+ ;;
472
+ " gen_wind" )
473
+ riverurl=" http://www.flickriver.com/groups/1159117@N24/pool/random/"
474
+ ;;
475
+ * )
476
+ # misc, mainly fog
477
+ riverurl=" http://www.flickriver.com/groups/1040464@N23/pool/random/"
478
+ ;;
479
+ esac
480
+ local flickrpage=$( wget -O - --quiet $( wget -O - " $riverurl " --quiet | grep " class=\" noborder\" target=\" _blank\" .*http://www.flickr.com/photos" | sed ' s#.*href=\"\([^\"]*\)\".*#\1#g' | uniq | shuf -n 1) )
481
+ local imagesizes=$( echo -e " $flickrpage " | grep Y.photo.init | sed ' s#.*Y.photo.init(\(.*\));#\1#g' | tr " }" " \n" )
482
+ for size in " Large 2048" " Original" " Large 1600" " Large\" " ; do
483
+ # not all flickr images provide every size, so we try to get the best one
484
+ # It is nicer to prefer a size with a specific width, that is why Original is not first
485
+ local imageurl=$( echo -e " $imagesizes " | grep " $size " | sed -e ' s#.*\(http[^"]*\).*"#\1#g' -e ' s#\\##g' )
486
+ if [[ -n " $imageurl " ]]; then
487
+ break
488
+ fi
489
+ done
490
+ if [[ -z " $imageurl " ]]; then
491
+ return 1
492
+ fi
493
+ if [[ -z " $FLICKRTMP " ]]; then
494
+ FLICKRTMP=$( mktemp)
495
+ fi
496
+ wget -O " $FLICKRTMP " " $imageurl " --quiet
497
+ echo " $FLICKRTMP "
498
+ }
499
+
449
500
450
501
# get current time via the last_build_date, which is not necesseraly the
451
502
# current time
@@ -747,7 +798,7 @@ while [[ $# -gt 0 ]] ; do
747
798
-p, --preview
748
799
Add images showing the weather forecast.
749
800
-r, --random:
750
- Choose the wallpaper randomly, only works when the directory is named in the config.
801
+ Choose the wallpaper randomly. If no directory is named in the config, it will try to get a fitting image from flickr .
751
802
-rd [warning|radar] [warning|radar] [germany|swiss], --radar [warning|radar] [warning|radar] [germany|swiss]:
752
803
Show a warning and/or a radarimage for a country. Wetteralarm (www.wetteralarm.ch) and Rain-Radar (meteoschweiz.admin.ch) for Switzerland, official warnings (http://www.dwd.de/) and a satellite-image (http://www.dlr.de/) for Germany.
753
804
-sr, --swiss-radar
@@ -766,7 +817,7 @@ while [[ $# -gt 0 ]] ; do
766
817
;;
767
818
768
819
--version)
769
- echo " izulu 0.5 .0"
820
+ echo " izulu 0.6 .0"
770
821
exit 0
771
822
;;
772
823
esac
0 commit comments