Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Astronomy Photo of the Day Wallpaper

  1. #1
    Join Date
    Feb 2007
    Location
    Virginia, USA
    Beans
    5
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Astronomy Photo of the Day Wallpaper

    Hello! I posted this in another thread, but I thought that it was a lot more applicable to this forum. The idea was to take the picture from this website, download it automatically every day, and set it to my wallpaper. I wrote a small shell script to do this, that I wanted to share. It's my first script, so I'd definitely like criticism and suggestions. I've got the script in a folder in my home folder called .wallpaper, and it runs every morning via a crontab entry. Let me know what you think!

    Code:
    #!/bin/bash
    
    # download image from apod site
    wget -A.jpg -R.txt -r -l1 --no-parent -nH http://antwrp.gsfc.nasa.gov/apod/astropix.html
    
    # move image from obscure folder to main folder, rename image
    find ./apod -name "*.jpg" | while read line ; do
    	mv "$line" "wallpaper.jpg"
    done
    
    # set image to wallpaper
    gconftool-2 -t string -s /desktop/gnome/background/picture_filename "blank.jpg"
    gconftool-2 -t string -s /desktop/gnome/background/picture_filename "/home/josh/.wallpaper/wallpaper.jpg"
    gconftool-2 -t string -s /desktop/gnome/background/picture_options "zoom"

  2. #2
    Join Date
    Nov 2006
    Beans
    Hidden!

    Smile Re: Astronomy Photo of the Day Wallpaper

    Creative!

  3. #3
    Join Date
    Apr 2007
    Beans
    14,781

    Re: Astronomy Photo of the Day Wallpaper

    Neat. Although I never use wallpapers, that is very cool.

  4. #4
    Join Date
    Aug 2009
    Location
    UK
    Beans
    138
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Astronomy Photo of the Day Wallpaper

    Any idea why I can't get crontab to run this script? Works fine from terminal? I even tried gnome-scheduler (after trying really hard to get it working) but still. The script seems to download the image but doesn't change the backdrop.
    A0753 8GB RAM 60GB SSD x64 12.10 GNOME 3 E520 * 4GB RAM 6TB RAID x64 12.04 GNOME 3 * ASROCK 330 2GB RAM 4GB CF x64 XBMCbuntu

  5. #5
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Astronomy Photo of the Day Wallpaper

    A way to do the download without the need to move the file around:

    Code:
    wget -q -O ~/.wallpaper/wallpaper.jpg "http://antwrp.gsfc.nasa.gov/apod/$(wget -q -O- http://antwrp.gsfc.nasa.gov/apod/astropix.html|grep -B1 '^<IMG SRC'|awk -F\" '/^<a href/ {print $2}')"
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  6. #6
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Astronomy Photo of the Day Wallpaper

    Quote Originally Posted by sisyphus1978 View Post
    Any idea why I can't get crontab to run this script? Works fine from terminal? I even tried gnome-scheduler (after trying really hard to get it working) but still. The script seems to download the image but doesn't change the backdrop.
    When started from cron it can not connect to you Gnome sessions's GConf server so it can't change the backdrop.
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  7. #7
    Join Date
    Aug 2009
    Location
    UK
    Beans
    138
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Astronomy Photo of the Day Wallpaper

    So how do I solve this exactly?

    /and here was me thinking I was a geek with conkyrc and nanorc...
    A0753 8GB RAM 60GB SSD x64 12.10 GNOME 3 E520 * 4GB RAM 6TB RAID x64 12.04 GNOME 3 * ASROCK 330 2GB RAM 4GB CF x64 XBMCbuntu

  8. #8
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Astronomy Photo of the Day Wallpaper

    One way is to use a script that periodically gets the new wallpaper and at that to your Gnome session:

    Code:
    #!/bin/sh
    
    sleep_until(){
     s=$((`date +%s --date "$*"` - `date +%s`))
     if [ $s -ge 0 ]; then
       sleep $s;
     fi
    }
    
    FILE=~/.wallpaper/wallpaper.jpg
    
    wget  -q -O "$FILE" "http://antwrp.gsfc.nasa.gov/apod/$(wget -q -O- http://antwrp.gsfc.nasa.gov/apod/astropix.html|grep -B1 '^<IMG SRC'|awk -F\" '/^<a href/ {print $2}')"
    
    gconftool-2 -t string -s /desktop/gnome/background/picture_filename "$FILE"
    gconftool-2 -t string -s /desktop/gnome/background/picture_options "zoom"
    
    sleep_until tomorrow
    exec $0
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  9. #9
    Join Date
    Aug 2009
    Location
    UK
    Beans
    138
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Astronomy Photo of the Day Wallpaper

    Thanks for all the scripts, but I'd more like to understand why crontab doesn't finish what I can do in the terminal and how to fix it? I can run crontab -e and I understand the commands, but I don't get why it doesn't change the desktop picture. The OP says they used the original script with a crontab entry. How does that work?

    Am I missing something obvious here?
    A0753 8GB RAM 60GB SSD x64 12.10 GNOME 3 E520 * 4GB RAM 6TB RAID x64 12.04 GNOME 3 * ASROCK 330 2GB RAM 4GB CF x64 XBMCbuntu

  10. #10
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Astronomy Photo of the Day Wallpaper

    If ~/.wallpaper/wallpaper.jpg already is your current wallpaper it works with cron as Gnome reloads the wallpaper when then corresponding file is modified. You don't need the gconftool stuff in that case.
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •