Run preference setting to user from Root

Treger
Contributor

Hi guys,

I am trying to set a default screensaver, @bentoms had some good commands on his site but I am now trying to apply it via script it looks like this:

#!/bin/sh
# grab current user
user=`ls -l /dev/console | cut -d " " -f 4`

#### Safari Opens With:
#### New Windows Open With:
#### HomePage:

defaults write /Users/$user/Library/Preferences/com.apple.Safari.plist AlwaysRestoreSessionAtLaunch -bool false
defaults write /Users/$user/Library/Preferences/com.apple.Safari.plist NewWindowBehavior -integer 0
defaults write /Users/$user/Library/Preferences/com.apple.Safari.plist HomePage -string "https://example.domain.com"

I just can't seem to get it to apply, I am testing through ARD to a machine and running as root, the command "succeeds" through ARD but then it doesn't apply to the user, if I change anything i get errors where it is says couldn't apply domain or no perms to write to com.apple.safari. I need to pass this through Casper to get this out and I just cannot see what I am doing wrong, wood for the trees and all that... Anyone got some ideas? I can see that it is pulling the user correctly but I don't think I am applying the command correctly to run it as root as the logged in user.

8 REPLIES 8

bentoms
Release Candidate Programs Tester

@Treger I deploy that now via a profile, works well.

Treger
Contributor

Apologies, not screensaver, HOMEPAGE!!!

Treger
Contributor

@bentoms How are you deploying via profile? Is that a Casper profile or like a user template on the machine?

bentoms
Release Candidate Programs Tester

2459d20087c34b77aa70ee58d248ee35

It's a custom profile, I created the com.apple.Safari.plist as wanted then uploaded to the JSS.

Treger
Contributor

I have just had a look at the plist of the machine I have been deploying to and the Homepage is set but the browser is still set on google as homepage, even after quitting...

Treger
Contributor

I do not have a plist setting for LastSafariVersionWithWelcomePage instead I have this: LastOSVersionSafariWasLaunchedOn and thats set to 10.8.3, I have changed that to 10.10.5... Did you manually input that string?

Treger
Contributor

@bentoms Ok, got it sorted Thanks! however the url bar at the top, I cannot search from, any idea what could be preventing that? I am assuming I have left something in the .plist??

Treger
Contributor

NVM, the machine I am using is having the same bug as stated here:

http://9to5mac.com/2016/01/27/safari-on-ios-and-mac-crashing-today-for-many-users-bug-related-to-safari-suggestions/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+9To5Mac-MacAllDay+%289+to+5+Mac+-+Apple+Intelligence%29