• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Changing Safari's Homepage with a little intellegence
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing Safari's Homepage with a little intellegence


  • Subject: Re: Changing Safari's Homepage with a little intellegence
  • From: Jeffrey Madson <email@hidden>
  • Date: Mon, 26 Sep 2016 09:10:56 -0500

Andrew,

Thanks, it works perfectly! How do I change it to http://www.apple.com only if it's pointing at http://google.com? Is there a way to read the file and say if it detects http://google.com then run the script you gave me and if not end the process? Thanks!

On Fri, Sep 23, 2016 at 2:35 PM, Andrew Oliver <email@hidden> wrote:
You never need to know what the current user name is. The OS will give this to you at runtime if you just ask correctly.

In this case you don’t even want the user’s name… or even their home directory. You want their preferences folder, in which case, ask for it:

set thisUsersPrefsFolder to (path to preferences)

this will give you the current user’s preferences directory. Since you are passing this to your shell command, a simple POSIX coercion is in order:

set thisUsersPrefsFolder to POSIX path of (path to preferences)

followed by:

do shell script "defaults write " & thisUsersPrefsFolder & "com.apple.Safari HomePage 'http://www.apple.com'"


On Sep 22, 2016, at 12:17 PM, Jeffrey Madson <email@hidden> wrote:

Hello Everyone,

Thanks for taking a peek at this. I'm trying to write a script that will change the current users Safari Home Page. I can do this using a terminal command in Applescript: do shell script "defaults write /Users/"current user"/Library/Preferences/com.apple.Safari HomePage http://www.apple.com but I have two problems. 1) I can only get this to work if I know who the "current user" is and I will never know so I need something that will change whoever is currently logged in. 2) I need to build in a little intellegence because I only want the address changed to http://www.apple.com if it's pointing at http://www.google.com (these are only examples). If it's pointing at anything besideshttp://www.google.com I don't want to change it. Can this be done in AppleScript and is there a better way then inserting the shell script? 

Thanks so much for any suggestions!

Jeff

--
____________________________________________________________

Jeffrey Madson | Endpoint Management | LSC Communications
800 Midway Road | Menasha, WI 54952
Office: 920.751.7942 | Cell: 920.915.8619
email@hidden
http://www.rrd.com
________________________________________________________________

____________________________________________________________


Jeffrey Madson | Endpoint Management | LSC Communications
800 Midway Road | Menasha, WI 54952

Office: 920.751.7942 | Cell: 920.915.8619

email@hidden

________________________________________________________________


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Changing Safari's Homepage with a little intellegence (From: Jeffrey Madson <email@hidden>)
 >Re: Changing Safari's Homepage with a little intellegence (From: Andrew Oliver <email@hidden>)

  • Prev by Date: Re: Another Sierra(?) issue
  • Next by Date: Mac OS Sierra & System Events For
  • Previous by thread: Re: Changing Safari's Homepage with a little intellegence
  • Next by thread: Re: Localization problem.
  • Index(es):
    • Date
    • Thread