Menu

#1 please add possibility od exact date, negative -g and get rid of potd.dat

1.0
open
nobody
None
2014-12-22
2014-12-10
JudoVana
No

hi!

This is nice script.

I would appreciate if possibility to download specific date would be included. This hack did it for me:

--- /home/jvanek/Desktop/bgr/potd-wikic-orig.sh
+++ /home/jvanek/Desktop/bgr/potd-wikic.sh
@@ -110,6 +110,9 @@
        for i in $(seq 0 $f);
        do
            date=`date +%F --date="+$i days"` #dates $i days in future.
+           if  [[ x$HARD_DATE != x ]] ; then 
+               date=$HARD_DATE
+           fi
            echo "$date (+$i days): $baseurl$date$lang"
            webpageFile="$date.html" #file to download webpage to (must be unique name for each day)
            imageFile="$date.jpg" #file to download image to (must be unique name for each day)
@@ -209,6 +212,9 @@
    #update todays POTD
    echo -n "creating POTD... "
    date=`date +%F`
+   if  [[ x$HARD_DATE != x ]] ; then 
+       date=$HARD_DATE
+   fi
    lastUpdate=`cat $lastUpdateFile` #check last update. If already updated then die.
    if [ "$lastUpdate" == "$date" ]; then
        echo -e " wallpaper already updated $date."
@@ -264,6 +270,7 @@
  -c     creates image with caption on bottom.
  -s     sets the desktop image (for Gnome, for now)
  -h     displays help
+ -D<YYYY-DD-MM>     override date and proceed with selected one
  -r<N>  removes images older than N days in the past. (needs to be implimented)

 options:
@@ -290,7 +297,7 @@

 OPTIND=1 #POSIX variable. Reset in case getopts has been used previously in the shell.

-while getopts "vh?g:csm:d:r:" opt; do #include list of varibles used. Add : after ones which require inpu
+while getopts "vh?g:csm:d:r:D:" opt; do #include list of varibles used. Add : after ones which require input
    case "$opt" in
    h|\?)
        show_help
@@ -298,6 +305,9 @@
        ;;
    v) #increase verbosity
        verbose="1"
+       ;;
+   D) #override date and use what user provided
+       HARD_DATE=$OPTARG
        ;;
    g)
        f=$OPTARG

Instead of this, few hints:
- get rid of that terribly history file. It have no sense.
- allow also negative numbers for -g
- some cleaning/maintainability after run:
- remove date.html page, date.jpg and description.png
or
- create date.html date.jpg date.description.jpg date.described.jpg (+ copied/linked to potd.jpg
- not sure what usecase is expected, but I consider - as greatest advantage - the image+description in one image. So I only made link of potd.html to my backgrounds folder, and selected that link as background. When in mood, just run this script, and woala, background changed.

Thanx fro great tool!

J.

ps: Please really really get rid of the potd.dat it is making work with this much less enjoyable

Discussion

  • DF

    DF - 2014-12-15

    Thanks for the suggestions.

    -Im not sure what history file your refering to.
    -Instead of using another argument (-D) to get a specic date, I added parsing to the -g so you can specify say -g2014-12-15 or use negative numbers.
    -I got rid of the description.png and potd.dat. I'm not really sure what you mean by getting rid of the <date>.jpg and <date>.html Do you mean just download the specified image as potd.jpg and not keep any other files around?
    -I made this tool to be able to download multiple images so even if you don't have internet, your background will still update each day using the buffer of images.
    -I'm guessing what you mean't by linking the potd.html is setting you backgroun to potd.jpg? I just tested it and you don't even need to run -s to set the background, it automatically updates it after the script updates potd.jpg.

     
  • JudoVana

    JudoVana - 2014-12-22

    I have not tested (but seen) the new changeset. Thank you!

    -Instead of using another argument (-D) to get a specic date, I added parsing to the -g so you can specify say -g2014-12-15 or use negative numbers.

    This sound great!

    -I got rid of the description.png and potd.dat.

    thank you!

    -Im not sure what history file your refering to.

    The potd.dat - it always complained - the file is a already downloaded (only based on the text in this file) although if the images were not here. Also was blocking theh negative numbers and exaxt date (becasue it was checking on pure -gt/-lt inisde script.

    Anyway - you are writing you get rid of it. And I'm grateful for it.
    SideNote - it is still mentioned in inside comments/documentation :)

    -I'm guessing what you mean't by linking the potd.html is setting you backgroun to potd.jpg? I just tested it and you don't even need to run -s to set the background, it automatically updates it after the script updates potd.jpg.

    Yes. And it make it even double cool. (so no op here) But maybe you cna get ird of custom gnome3 code, as it is actually working without it. (but it is completely unnecessary)

    I'm not really sure what you mean by getting rid of the <date>.jpg and <date>.html Do you mean just download the specified image as potd.jpg and not keep any other files around?
    -I made this tool to be able to download multiple images so even if you don't have internet, your background will still update each day using the buffer of images.

    Hm yes. I understand this. And yes, it is necessary functionality. But you must see that (in original version, not sure how it is now) that it could not work as intended:

    You downloaded image as date.jpg and description file as date.html (well those two are enough to keep history instead of the removed potd.dat)
    Then description.png is generated, and littlebit later image+description is generated (potd.jpg). In this moment the description.png is not needed and may be removed.

    Now I understand your intentions a bit better, so my suggestion can be narrowed to two usecases:
    usecase1:
    keep date.html image.html, generate potd.jpg (+remove description.png)
    usecase2:
    instead of generating potd.jpg, generated date-potd.png and link it as potd.jpg (so non-gnome3 environments can automatically refres) - and remove date.html, date.jpg, and of course description.png :)

    The intersection of above is quite stupid. So on my end it is ok as it is now. And I'm thankful for your will to fix this ticket. As I told, I have not tested, but seems like ok-to-close this.

    J.

     

Log in to post a comment.