script to change the login window background image on mac osx

Below is a python script that will randomly pick an image, from a directory you specify (e.g., /Users/Shared/backgrounds), and make it the login window background. This is for macs. It works on my mac mini. The trick is to replace /Library/Desktop Pictures/Aqua Blue.jpg with the image you want to be the background.

#!/usr/bin/python import string import os import glob import shutil from random import randrange os.chdir("/Users/Shared/backgrounds") ilist = glob.glob('*.jpg') i = randrange(len(ilist)) #print ilist[i] shutil.copyfile(ilist[i], '/Library/Desktop Pictures/Aqua Blue.jpg')

Notes

  1. You don't get to see the result of this script until someone logs out.
  2. I added a line to /etc/daily.local, so the script is called each night around 3am. If your machine goes to sleep every night, it won't get run (see anacron below for one solution).
  3. You need to create the directory /Users/Shared/backgrounds and fill it with .jpg files.
  4. I don't know if this script works with filenames that have spaces in them!
  5. If you like Aqua Blue.jpg, make a copy of it before you run this script.

Useful links


back to helps
Last Modified: Tue 26 Feb 2008 12:53:22 PM EST