Hello everyone:
I need your help in writing an simple script for my MacBook Pro laptop (Mac OS X Snow Leopard) that was issued to me by my school district. Unfortunately, the district wants to control the background on my desktop (it always shows the district logo and motto) and the homepage on Safari (it always opens to the district homepage.) I can change these once my laptop boots up, but when I do restart it, the desktop background and Safari homepage revert back to the district’s choices. I know that these changes were made by the district’s IT people using Workgroup Manager and Open Directory, and I don’t want to get into changing those settings. I was advised in a Mac Forum at About.com that I could write a script to change the desktop and Safari homepages, but I just don’t know how. I’ve looked at a number of AppleScript sites, but they’re pretty complex and hard to follow. I’m just learning how to write scripts, so is there a template out there I can use or can someone walk me through the process? The script has to run whenever I login.
Thanks for your help, and I do hope to hear from you soon.
Sincerely,
Chris
Model: MacBook Pro
AppleScript: 2.1.2
Browser: Internet Explorer 7.0
Operating System: Mac OS X (10.6)
Hi,
adjust the path to the picture (HFS path!) and the URL, save the script as application and add it to the startup items
tell application "System Events" to set picture of current desktop to file "disk:path:to:pic.ext"
do shell script "defaults write com.apple.Safari HomePage 'http://macscripter.net/'"
Stefan:
Ok, here’s what I’ve got so far. I’m new to the Mac, so bear with me. Does anything need to be corrected? Also, at the risk of sounding like “newbie,” 1) What does HFS mean? 2) How do I add the script to the start up items?
Thanks for your help!
Chris
HFS path is a literal string path to the picture, starting with a disk name and colon separated e.g.
“Macintosh HD:Users:MyUser:Pictures:myFavoritePic.jpg”
save the script somewhere in your home folder and add it in System Preferences > Accounts > (Tab) Login Items
Stefan:
I just realized I didn’t show you what the script looked like. Here it is:
tell application “System Events” to set picture of current desktop to file “Macintosh HD:Library:Desktop Pictures:Nature:Aurora.jpg”
do shell script “defaults write com.apple.Safari HomePage ‘http://home.core.com/’”
I didn’t do this in AppleScript yet, I did it in Word, but I’m assuming I can cut and paste it into Applescript. Is that correct?
I think I figured out how to save this as a startup item. I was able to get to the login items, clicked on the lock to make changes, and then clicked on the + under the login items to add the script. Once I’ve saved the script in Applescript and saved it, that’s all I’ll have to do, correct?
Thanks again!
Chris
Correct, you can test it by changing both parameters to something else and then log out/in
Stefan:
Well it works … almost. What happens on after I log in is that AppleScript starts up and shows the script. I have to manually click on the green Run button to run the script. What should I do?
Chris