A script to pick a random login window background

Dec 31, '07 07:30:04AM

Contributed by: V.K.

I really this older hint, on how to change the login window background by telling the system to look for the image in another location, but I want to suggest a small variation of it.

I like to constantly change my backgrounds. I have a directory with a bunch of background pictures, so I wrote a simple AppleScript which takes a random file from this directory and saves it as the picture used as the login window background. Mine is named myloginwindow.jpg, and it sits in my Public folder.

tell application "Finder"
  set theList to files of folder "wallpaper" of startup disk
  set theNum to random number from 1 to (count theList) with seed (time of (current date))
  set item1 to item theNum of theList
  set folder2 to folder "Public" of folder "username" of folder "Users" of startup disk
  tell application "Image Events"
    launch
    set this_image to open item1 as alias
    set typ to this_image's file type
    tell application "Finder" to set new_item2 to (folder2 as string) & ("myloginwindow.jpg" as string)
    save this_image in new_item2 as typ
    close this_image
  end tell
end tell
Then I saved the AppleScript as an application, and added it to the login items for my account. Now every time I log in, I see a different login background. Since I really know nothing about AppleScripting, the above is probably not ideal (please feel free to suggest improvements in the comments), but it works for me.

[robg adds: I haven't tested this one, but to make it work, you'll also have to have used the linked hint to specify a new location for the login background images.]

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20071231051934763