diff --git a/README.md b/README.md index 94d3506..f8fc490 100644 --- a/README.md +++ b/README.md @@ -15,18 +15,21 @@ http://en.wikipedia.org/wiki/Astronomy_Picture_of_the_Day http://apod.nasa.gov/apod/astropix.html Tested on, OSX 10.7.4 -During testing, it just sets the background for the space the terminal is on when it is run. I have no idea how this will interact with cron. I'll find out over the next few days. +During testing, it just sets the backgroud for the space you happen to be on at 6AM, or when the computer unsleeps next. + Development: ===== -I just modified it to work on OSX, and Commented out the use of PIL and the resizing of the image, as OSX can deal with that itself. +I just modified it to work on OSX, and commented out the use of PIL and the resizing of the image, as OSX can deal with that itself. +Now I've learned how to set a up a launchd plist file to make it run once a day. Installation: ===== * Place the file wherever you like and chmod +x it to make it executable * Set the defaults in the file -* Edit cron.txt to properly reference the file, and adjust the time at which it runs if you want. (First number is minutes, next is hours.) +* Move net.belaire.nasa_apod_desktop.plist to ~/Library/LaunchAgents +* Run 'launchdctl load ~/Library/LaunchAgents/net.belaire.nasa_apod_desktop.plist'. To Do: ===== diff --git a/cron.txt b/cron.txt deleted file mode 100644 index f42b9dd..0000000 --- a/cron.txt +++ /dev/null @@ -1,2 +0,0 @@ -0 0 * * * /User/theobelaire/github/nasa-apod-desktop/nasa_apod_desktop.py > /dev/null - diff --git a/nasa_apod_desktop.py b/nasa_apod_desktop.py index 9aad7d6..921f143 100755 --- a/nasa_apod_desktop.py +++ b/nasa_apod_desktop.py @@ -44,23 +44,12 @@ INSTALLATION Ensure you have Python installed, which is required for OSX. - -Set your resolution variables and your download path (make sure it's writeable): +Edit the plist file to have the proper path to the python script. +Move the plist file into ~/Library/LaunchAgents/ folder. +Edit the following path to somewhere on your computer that is writable. ''' DOWNLOAD_PATH = '/Users/theobelaire/backgrounds/' -''' - -RUN AT STARTUP -To have this run whenever you startup your computer, perform the following steps: -1) Click on the settings button (cog in top right) -2) Select "Startup Applications..." -3) Click the "Add" button -4) Enter the following: -Name: NASA APOD Desktop -Command: python /path/to/nasa_apod_desktop.py -Comment: Downloads the latest NASA APOD and sets it as the background. -5) Click on the "Add" button -''' + import commands import urllib import urllib2 @@ -69,7 +58,7 @@ #from PIL import Image from sys import stdout -from appscript import app, mactypes +from appscript import app, mactypes, its # Configurable settings: @@ -149,6 +138,15 @@ def set_OSX_wallpaper(file_path): print "Setting the wallpaper" app('Finder').desktop_picture.set(mactypes.File(file_path)) +def set_all_OSX_wallpapers(file_path): + ''' Sets the new image as the wallpaper for all moniters. Untested. If someone want to ship me a moniter I'd be happy to test it though... ''' + + se = app('System Events') + desktops = se.desktops.display_name.get() + for d in desktops: + desk = se.desktops[its.display_name == d] + desk.picture.set(mactypes.File(file_path)) + def print_download_status(block_count, block_size, total_size): written_size = human_readable_size(block_count * block_size)