• 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: Shane Stanley <email@hidden>
  • Date: Sat, 24 Sep 2016 09:57:43 +1000

On 24 Sep. 2016, at 5:35 am, 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'"

Actually you don't want *any* path -- defaults generally operates on domains, not paths. In this case the path is pointing to where the domain's values are stored, and it will therefore write to that file -- but the defaults domain is likely to write over it.

In fact, man defaults has this to say in Sierra:

WARNING: The defaults command will be changed in an upcoming
               major release to only operate on preferences domains. General
               plist manipulation utilities will be folded into a different
               command-line program.

All of which is a bit academic in this case, because as far as I can see Safari no longer stores its home page under the key of HomePage. In fact, I don't believe it saves it in com.apple.Safari at all. 

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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: Sierra and URLByDeletingLastPathComponent
  • Next by Date: AppleScript in Sierra
  • Previous by thread: Re: Changing Safari's Homepage with a little intellegence
  • Next by thread: Re: Changing Safari's Homepage with a little intellegence
  • Index(es):
    • Date
    • Thread