Skip to content

Commit

Permalink
Added multiscreen support
Browse files Browse the repository at this point in the history
Untested, but I think it might work.  Code from stackexchange.
  • Loading branch information
Theo Belaire committed Aug 1, 2012
1 parent 1d9e80e commit 607d07c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
=====
Expand Down
2 changes: 0 additions & 2 deletions cron.txt

This file was deleted.

30 changes: 14 additions & 16 deletions nasa_apod_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 607d07c

Please sign in to comment.